Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Notepad++ be configured to recognize compiler error messages and jump to the respective location?

Tags:

notepad++

ide

I am building some fairly large code on a machine without an IDE, but with Notepad++.

The compilation results are redirected to a file and sometimes, there are error messages, which satisfy a well defined regex.

I wonder if NPP has a plugin, which would parse the log file, recognize the error/warning messagess and let me navigate between the respective error/warning locations.

EDIT

Here is a typical example of the output (produced by make running MSVC cl.exe compiler):

/cygdrive/c/vs2010/VC/Bin/cl   -Zi -nologo -MD /D _STATIC_CPPLIB  -FdC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/Win32SurfaceData.pdb -FmC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/Win32SurfaceData.map -W3 -DD3D_OVERLOADS  -DUNICODE -D_UNICODE  -DWIN32 -DIAL -D_LITTLE_ENDIAN -DWIN32 -D_X86_ -Dx86  -DWIN32_LEAN_AND_MEAN -I. -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders -I../../../src/windows/javavm/export -I../../../src/share/javavm/export -I../../../src/share/javavm/include -I../../../src/windows/javavm/include -I../../../src/share/native/common -I../../../src/windows/native/common -I../../../src/share/native/sun/awt -I../../../src/windows/native/sun/awt -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders/../../java/jvm -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj -I../../../src/share/native/common -I../../../src/windows/native/sun/windows -IC:/PROGRA~2/MICROS~1/Include -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/awt/image -I../../../src/share/native/sun/java2d/loops -I../../../src/share/native/sun/java2d -I../../../src/windows/native/sun/java2d -I../../../src/share/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/d3d -I../../../src/windows/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/windows -I../../../src/share/native/sun/font -I../../../src/share/native/sun/java2d/pipe -I../../../src/share/native/sun/dc/path -I../../../src/share/native/sun/dc/doe -I../../../src/share/native/sun/awt/debug -I../../../src/windows/native/sun/awt  -I../../../src/share/native/sun/awt/medialib   -DINTERNAL_BUILD  -c -FoC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/Win32SurfaceData.obj  ../../../src/windows/native/sun/awt/../java2d/windows/Win32SurfaceData.cpp
Win32SurfaceData.cpp
../../../src/windows/native/sun/awt/../java2d/windows/Win32SurfaceData.cpp(478) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
/cygdrive/c/vs2010/VC/Bin/cl   -Zi -nologo -MD /D _STATIC_CPPLIB  -FdC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WinBackBufferSurfaceData.pdb -FmC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WinBackBufferSurfaceData.map -W3 -DD3D_OVERLOADS  -DUNICODE -D_UNICODE  -DWIN32 -DIAL -D_LITTLE_ENDIAN -DWIN32 -D_X86_ -Dx86  -DWIN32_LEAN_AND_MEAN -I. -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders -I../../../src/windows/javavm/export -I../../../src/share/javavm/export -I../../../src/share/javavm/include -I../../../src/windows/javavm/include -I../../../src/share/native/common -I../../../src/windows/native/common -I../../../src/share/native/sun/awt -I../../../src/windows/native/sun/awt -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders/../../java/jvm -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj -I../../../src/share/native/common -I../../../src/windows/native/sun/windows -IC:/PROGRA~2/MICROS~1/Include -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/awt/image -I../../../src/share/native/sun/java2d/loops -I../../../src/share/native/sun/java2d -I../../../src/windows/native/sun/java2d -I../../../src/share/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/d3d -I../../../src/windows/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/windows -I../../../src/share/native/sun/font -I../../../src/share/native/sun/java2d/pipe -I../../../src/share/native/sun/dc/path -I../../../src/share/native/sun/dc/doe -I../../../src/share/native/sun/awt/debug -I../../../src/windows/native/sun/awt  -I../../../src/share/native/sun/awt/medialib   -DINTERNAL_BUILD  -c -FoC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WinBackBufferSurfaceData.obj  ../../../src/windows/native/sun/awt/../java2d/windows/WinBackBufferSurfaceData.cpp
WinBackBufferSurfaceData.cpp
/cygdrive/c/vs2010/VC/Bin/cl   -Zi -nologo -MD /D _STATIC_CPPLIB  -FdC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WBufferStrategy.pdb -FmC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WBufferStrategy.map -W3 -DD3D_OVERLOADS  -DUNICODE -D_UNICODE  -DWIN32 -DIAL -D_LITTLE_ENDIAN -DWIN32 -D_X86_ -Dx86  -DWIN32_LEAN_AND_MEAN -I. -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders -I../../../src/windows/javavm/export -I../../../src/share/javavm/export -I../../../src/share/javavm/include -I../../../src/windows/javavm/include -I../../../src/share/native/common -I../../../src/windows/native/common -I../../../src/share/native/sun/awt -I../../../src/windows/native/sun/awt -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders/../../java/jvm -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj -I../../../src/share/native/common -I../../../src/windows/native/sun/windows -IC:/PROGRA~2/MICROS~1/Include -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/awt/image -I../../../src/share/native/sun/java2d/loops -I../../../src/share/native/sun/java2d -I../../../src/windows/native/sun/java2d -I../../../src/share/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/d3d -I../../../src/windows/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/windows -I../../../src/share/native/sun/font -I../../../src/share/native/sun/java2d/pipe -I../../../src/share/native/sun/dc/path -I../../../src/share/native/sun/dc/doe -I../../../src/share/native/sun/awt/debug -I../../../src/windows/native/sun/awt  -I../../../src/share/native/sun/awt/medialib   -DINTERNAL_BUILD  -c -FoC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WBufferStrategy.obj  ../../../src/windows/native/sun/windows/WBufferStrategy.cpp
WBufferStrategy.cpp
/cygdrive/c/vs2010/VC/Bin/cl   -Zi -nologo -MD /D _STATIC_CPPLIB  -FdC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WPrinterJob.pdb -FmC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WPrinterJob.map -W3 -DD3D_OVERLOADS  -DUNICODE -D_UNICODE  -DWIN32 -DIAL -D_LITTLE_ENDIAN -DWIN32 -D_X86_ -Dx86  -DWIN32_LEAN_AND_MEAN -I. -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders -I../../../src/windows/javavm/export -I../../../src/share/javavm/export -I../../../src/share/javavm/include -I../../../src/windows/javavm/include -I../../../src/share/native/common -I../../../src/windows/native/common -I../../../src/share/native/sun/awt -I../../../src/windows/native/sun/awt -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/CClassHeaders/../../java/jvm -IC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj -I../../../src/share/native/common -I../../../src/windows/native/sun/windows -IC:/PROGRA~2/MICROS~1/Include -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/awt/image -I../../../src/share/native/sun/java2d/loops -I../../../src/share/native/sun/java2d -I../../../src/windows/native/sun/java2d -I../../../src/share/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/d3d -I../../../src/windows/native/sun/java2d/opengl -I../../../src/windows/native/sun/java2d/windows -I../../../src/share/native/sun/font -I../../../src/share/native/sun/java2d/pipe -I../../../src/share/native/sun/dc/path -I../../../src/share/native/sun/dc/doe -I../../../src/share/native/sun/awt/debug -I../../../src/windows/native/sun/awt  -I../../../src/share/native/sun/awt/medialib   -DINTERNAL_BUILD  -c -FoC:/openjdk/OUTPUT~1/tmp/sun/sun.awt/awt/obj/WPrinterJob.obj  ../../../src/windows/native/sun/windows/WPrinterJob.cpp
WPrinterJob.cpp
../../../src/windows/native/sun/windows/WPrinterJob.cpp(74) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
../../../src/windows/native/sun/windows/WPrinterJob.cpp(117) : error C2664: 'JNIEnv_::NewString' : cannot convert parameter 1 from 'LPWSTR' to 'const jchar *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
../../../src/windows/native/sun/windows/WPrinterJob.cpp(142) : error C2664: 'JNIEnv_::NewString' : cannot convert parameter 1 from 'LPTSTR' to 'const jchar *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
like image 623
mark Avatar asked Dec 18 '12 11:12

mark


2 Answers

Since you have all the output saved in a log file, what DeusAphor suggests is what I would also do.

Another option would be to let the compiler output direct itself normally into NppExec's console and then set NppExec to open the offended source file and jump to the line dictated by the compiler.

This can achieved by first noticing the pattern of the error messages emit by you compiler, and then open the dialog box: Plugins->NppExec->Console Output Filters->[Highlight] tab. Quick samples of the variables recognized by the plug-in are presented inside that tab.

For mingw32 GCC, for example, error messages appear on the output console with the following pattern:

FILE: LINE:some_other_num: error type: error_desription

Thus, inside the [Highlight] tab of the dialog, you can add it with a wildcard syntax into the first textbox, as shown in the following picture (look at the top row):

enter image description here

(you may need to replace %FILE% with %ABSFILE%, depending on your compiler and/or Windows version)

Don't forget to enable the check-mark in front of the textbox (you may also define some color and/or text styles, from the options presented next to the textbox).

Now before closing the NppExec dialog, go to its [Replace] tab and enable the option at the top: "Enable Replacing Filters".

Lastly, close the NppExec dialog with OK and make sure that the menu entry* Plugins->NppExec->Console Output Filters is checked. If not, check it.

If everything went well, you should now be able to double click onto any error message shown on NppExec's output console, having it open the relative file and moving the cursor to the indicated line.

Another option would be to install an alternative terminal to the Windows command-prompt, like MSYS for example, that comes either embedded or as a stand-alone download of the mingw tool-chain.

However, it requires familiarity with the Unix-like shell utilities and involves also writing your own Np++ or NppExec scripts. This post may be useful as a starting point, although it discusses Cygwin (a Unix layered environment on top Windows).

like image 169
Harry K. Avatar answered Nov 08 '22 04:11

Harry K.


Alright, so what I would do is use "Find in Files" ...

Given your current example I just put the text to find as "error"; If you wanted to include warnings; enable regex and search "error|warning"

Directory is of course the directory to search in..

Using a filter you can tell it to only look at files with X name. Example : "compiler-output3844.txt" you would use "compiler-output*.txt"

This will give you something like so...

Find in Files

like image 33
DeusAphor Avatar answered Nov 08 '22 02:11

DeusAphor