2017-08-29 168 views
2

自從我加入了這個項目,我的編譯輸出一直期待這樣的:尋找問題的宏觀

[ 0%] Building CXX object lib-tests/gmock/CMakeFiles/gmock_main.dir/gtest/src/gtest-all.cc.o 
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name 
[ 0%] Building CXX object lib-tests/gmock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o 
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name 
[ 0%] Building CXX object lib-tests/gmock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o 
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name 
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name 
[ 0%] Linking CXX static library libgmock_main.a 
[ 0%] Built target gmock_main 

等。整個項目編譯的每個文件之間始終存在高達100%的警告。這只是編譯的開始,它從谷歌測試庫開始,但我並不特別懷疑它是不良宏的來源。 (但它可能)這很奇怪,因爲當我谷歌這個警告,人們得到了代碼和宏的快照,但我的編譯器不這樣做,我只是得到警告。

我在Debian上使用gion編譯器和cmake的CLion。我已經嘗試了多個正則表達式來查找沒有空格的宏,但沒有找到任何成功。我應該怎麼做才能確定產生此警告的宏?

+0

通過逐步評論(或者用一些'#error')來評估有問題的標題? – Jarod42

+0

您可以將編譯器輸出設置爲verbose並查看該宏是否將打印到構建日誌中的某個位置? –

+2

你的命令行看起來像什麼?可能有一些奇怪的「-Dxxx」。 – stefan

回答

1

感謝@ stefan對我的問題的評論,從我的CMakeLists.txt文件中刪除2個標誌修復了這個問題。

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -O0 -g -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_RULE_MESSAGES:BOOL=ON") 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -O0 -g") 

我仔細檢查了和去除這些標誌不隱藏編譯器警告像未使用的變量等等。我不知道刪除這些標誌可以有什麼樣的影響,雖然。