4.7.1. Compiling simple C and Pas-programs

1. You can edit, compile & run simple C-programs directly from Notepad++. All you need is the following:

1) download tcc (Tiny C Compiler is a freeware C-compiler, about 1 MB in archive)

2) unpack tcc to "C:\tools\tcc" or create "tcc" subfolder in your Notepad++ folder (for example, "C:\Program Files\Notepad++\tcc") and unpack tcc there

3) run Notepad++ and call the "Execute NppExec Script..." dialog (Plugins -> NppExec -> Execute NppExec Script... - or just press F6).

4) type these commands in the "Execute NppExec Script..." dialog:

4.1) if tcc is placed in C:\tools\tcc

// save current file 
NPP_SAVE
// enable the built-in error highlight filter locally
NPE_CONSOLE local -- x+
// compile & run with tcc 
C:\tools\tcc\tcc.exe -run "$(FULL_CURRENT_PATH)"

4.2) if tcc is placed in $(NPP_DIRECTORY)\tcc

// save current file 
NPP_SAVE
// enable the built-in error highlight filter locally
NPE_CONSOLE local -- x+
// compile & run with tcc 
"$(NPP_DIRECTORY)\tcc\tcc.exe" -run "$(FULL_CURRENT_PATH)"

5) save these commands: press Save... button, type "tcc-run" (this is a name of your script) and press Save.

Now, when you have a C source file opened in Notepad++, you can call the "Execute NppExec Script..." dialog, select "tcc-run" and press OK to compile & run this C-file.

In this case tcc works as an interpreter for your C source file (its option "-run" does it: use "tcc -?" to learn more). If you need to produce the output .exe file, just remove the "-run" option.

 

2. By the similar technique, you can compile Pascal files using Free Pascal (FPC):

NPP_SAVE // save current file
set local PathToFpcExe = C:\FPC\2.6.0\bin\i386-win32 // path to fpc.exe
env_set local PATH = $(SYS.PATH);$(PathToFpcExe) // add the path to fpc.exe to %PATH%
cd $(CURRENT_DIRECTORY) // go to directory of the current file
NPE_CONSOLE local -- x+ // enable the built-in error highlight filter locally
fpc "$(FILE_NAME)" // use fpc.exe to compile