RetroCoders Community

C / C ++ Programming => C / C++ => Topic started by: stigma on Jan 16, 2023, 04:35 PM

Title: setting Notepad++ for compiling C code
Post by: stigma on Jan 16, 2023, 04:35 PM

Here is the notepad++ nppexec plugin script commands that I use to compile my C code:

You need to change the path to the mingw32/bin in the code:

npp_save
ENV_SET InputFile = $(CURRENT_DIRECTORY)\$(FILE_NAME)
ENV_SET OutDir = $(CURRENT_DIRECTORY)
ENV_SET OutputFile = $(CURRENT_DIRECTORY)\$(NAME_PART).exe
ENV_SET InRes = $(CURRENT_DIRECTORY)\Res\NewComCtl.rc
ENV_SET ResObj = $(CURRENT_DIRECTORY)\Res\manifest.o

cd $(CURRENT_DIRECTORY)
//cmd /c C:\mingw32\bin -i %InRes% -F pe-i386 -o %ResObj%
cd C:\mingw32\bin
cmd /c del %OutputFile% >nul 2>&1
// -Wpedantic %ResObj%
cmd /c gcc -Wno-unused-label -Wall -std=c99 -Wno-unknown-pragmas -O1  -Wfatal-errors -s "%InputFile%" -luser32 -lgdi32 -L "%OutDir%" -o "%OutputFile%
if "$(EXITCODE)" == "0" then
  cd OutDir
  cmd /c start /wait cmd " /c %OutputFile% " & pause
endif
Title: Re: setting Notepad++ for compiling C code
Post by: stigma on Jan 16, 2023, 05:20 PM
I have codeblocks however, using npp as ide means I'm learning on a text editor rather than an actual IDE, and there is a difference. One of them is paying attention to small details that otherwise would be ready-made by the ide. That way, you "learn the hard way," but you "have to be less lazy" and pay attention to minor syntax errors - plus, you don't need to create a full "project" just to build and run a source file in C...
Title: Re: setting Notepad++ for compiling C code
Post by: stigma on Jan 19, 2023, 10:19 PM
Here is an improved nppexec script for compiling and running C code:

npp_save
ENV_SET InputFile = $(CURRENT_DIRECTORY)\$(FILE_NAME)
ENV_SET OutDir = $(CURRENT_DIRECTORY)
ENV_SET OutputFile = $(CURRENT_DIRECTORY)\$(NAME_PART).exe
ENV_SET InRes = $(CURRENT_DIRECTORY)\Res\NewComCtl.rc
ENV_SET ResObj = $(CURRENT_DIRECTORY)\Res\manifest.o

cd $(CURRENT_DIRECTORY)
//cmd /c C:\mingw32\bin -i %InRes% -F pe-i386 -o %ResObj%
cd C:\mingw32\bin
cmd /c del %OutputFile% >nul 2>&1
// -Wpedantic %ResObj%
cmd /c gcc -Wno-unused-label -Wall -std=c99 -Wno-unknown-pragmas -O1  -Wfatal-errors -s "%InputFile%" -luser32 -lgdi32 -L "%OutDir%" -o "%OutputFile%
if "$(EXITCODE)" == "0" then
cmd /c start /wait cmd "/c cd /d %OutDir% & %OutputFile% & timeout /t -1"
endif