1

我正在設置一個項目。我使用boost單元測試來完成骨架測試。不幸的是,大量的警告是從宏觀擴張中產生的。有沒有辦法禁用這些,而不必指定個人行號?使用叮噹整理處理大量的增強單元測試相關警告

即使我有// NOLINT,也會發生這種情況。

一個例子:

/home/peter/checkouts/canopen-gateway/./unittests/projs/server/exe/testunit-tcp-socket.cpp:12:1: warning: construction of 'end_suite12_registrar12' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp] 
BOOST_AUTO_TEST_SUITE_END() // NOLINT 
^ 
/usr/include/boost/test/unit_test_suite.hpp:62:73: note: expanded from macro 'BOOST_AUTO_TEST_SUITE_END' 
#define BOOST_AUTO_TEST_SUITE_END()          \ 
                     ^
/usr/include/boost/test/unit_test_suite.hpp:209:62: note: expanded from macro '\BOOST_AUTO_TU_REGISTRAR' 
static boost::unit_test::ut_detail::auto_test_unit_registrar BOOST_JOIN(BOOST_JOIN(test_name, _registrar), __LINE__) 
                  ^
/usr/include/boost/config/suffix.hpp:544:28: note: expanded from macro 'BOOST_JOIN' 
#define BOOST_JOIN(X, Y) BOOST_DO_JOIN(X, Y) 
         ^
/usr/include/boost/config/suffix.hpp:545:31: note: expanded from macro 'BOOST_DO_JOIN' 
#define BOOST_DO_JOIN(X, Y) BOOST_DO_JOIN2(X,Y) 
          ^
/usr/include/boost/config/suffix.hpp:546:32: note: expanded from macro 'BOOST_DO_JOIN2' 
#define BOOST_DO_JOIN2(X, Y) X##Y 
          ^
note: expanded from here 
/usr/include/boost/test/unit_test_suite_impl.hpp:284:17: note: possibly throwing constructor declared here 
    explicit auto_test_unit_registrar(int); 

回答

1

你可能不粘貼整個錯誤消息,但在某個地方應該有這樣一行

警告:遞歸宏 禁用擴展[ -Wdisabled-macro-expansion]

您可以通過將-Wno-disabled-macro-expansion傳遞給clang命令行。

+0

謝謝。讓我檢查什麼時候回去工作。 –

+0

@PeterBingham有用嗎? – TemplateRex

+0

不幸的是我沒有足夠的時間來追求這一點,因爲問題不再發生。我破解了一個修復程序,以停止找到boost庫的clang-tidy,這樣我就可以得到更短的錯誤列表,抱怨丟失的頭文件。 無論如何,我沒有試過你的命令行選項,並得到: clang-tidy:未知的命令行參數'-Wno-disabled-macro-expansion'。嘗試:'clang-tidy -help' 但是,我使用的是舊的Ubuntu支持的叮噹聲版本,因此您的選擇可能是一項新功能。 如果我在將來使用你的建議得到這個工作,那麼我記下它! –