2012-12-18 22 views
5

我在沒有IDE的機器上構建了一些相當大的代碼,但是使用Notepad ++。可以將Notepad ++配置爲識別編譯器錯誤消息並跳轉到相應位置?

編譯結果重定向到一個文件,有時,有錯誤消息,其滿足一個良好定義的正則表達式。

不知NPP有一個插件,它會分析日誌文件,認識到錯誤/警告messagess,讓我相應的錯誤/警告位置之間進行導航。

編輯

這裏是輸出(由make生產運行的cl.exe MSVC編譯器)的一個典型的例子:

/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 
+0

你能發表一段包含錯誤的輸出嗎? - 我不知道任何插件,但有適當的正則表達式,你可以做一個「在文件中查找」,並列出所有錯誤及其各自的位置輸出。 – DeusAphor

回答

1

好了,所以我會做的是使用「查找文件」 ...

鑑於當前的例子中,我只是把文字作爲尋找‘錯誤’;如果你想包括警告;使正則表達式和搜索|

目錄當然是在搜索目錄「錯誤預警」 ..

使用過濾器,你可以告訴它只能看與X名的文件。 例:「編譯器output3844.txt」你可以使用「編譯器輸出* .TXT」

這會給你的東西是這樣的...

Find in Files

+1

這就是我今天所做的。至少可以說,與點擊相比,這並不是很方便。 – mark

6

既然你把所有的輸出保存在日誌文件中,DeusAphor建議的是我也會做的。

另一種選擇是讓編譯器直接輸出通常本身爲NppExec的控制檯,然後設置NppExec打開冒犯源文件,並跳轉到編譯器所規定的線。

這可以通過首先注意到編譯器發出的錯誤消息的模式,然後打開對話框來實現:Plugins-> NppExec-> Console Output Filters - > [Highlight]選項卡。在該選項卡中顯示由插件識別的變量的快速樣本。

對於mingw32的GCC,例如,錯誤消息顯示用下面的圖案在輸出控制檯:

FILELINE:some_other_num:錯誤類型:error_desription

因此,在對話框的[突出顯示]選項卡內,可以使用通配符語法將其添加到第一個文本框中,如下圖所示(請查看第一行):

enter image description here

你可能需要更換%FILE%與%ABSFILE%,這取決於你的編譯器和/或Windows版本

不要忘記使複選標記在文本框的前面(您也可以從文本框旁邊的選項中定義一些顏色和/或文本樣式)。

現在在關閉NppExec對話框之前,請轉至其[替換]選項卡,並啓用頂部的選項:「啓用替換篩選器」。

最後,確定關閉對話框NppExec並確保該菜單項*插件 - > NppExec->控制檯輸出濾波器是檢查。如果沒有,請檢查它。

如果一切順利,您現在應該可以雙擊NppExec輸出控制檯上顯示的任何錯誤消息,讓它打開相關文件並將光標移動到指定的行。

另一種選擇是安裝Windows命令提示符的替代終端,例如MSYS,它可以嵌入或作爲mingw tool-chain的獨立下載。

但是,它需要熟悉類Unix的shell實用程序,並且還需要編寫自己的Np ++或NppExec腳本。 This post可能作爲一個起點,雖然它討論了Cygwin(頂層Windows上的Unix分層環境)。

+0

對此答案+1。我使用記事本++「Je suis Charlie edition」「構建時間:2015年1月10日-17:20.21」,我不需要在「替換」選項卡中啓用「啓用替換篩選器」。因此,不會選中「控制檯輸出過濾器...」,因爲它會在啓用「啓用替換過濾器」檢查的情況下進行檢查。 – miracle173

+0

對我來說,棘手的部分是將日誌文件的內容放入NppExec控制檯輸出中。最後,我發現我可以通過從NppExec控制檯執行「cat 」來完成。 (我希望「type」能夠工作,看到我在Windows機器上,但它沒有。) – Alan

相關問題