Qt5 "Clang Code Model" 一些设置
来源 https://www.cnblogs.com/cppskill/p/11745893.html
1、有些设置 可能这里在设置了,到别的地方(例如换了一个机子) 又要设置,这样的话 在不熟练的时候 手动敲进去会比较慢,这里 先记录下来 以后要用 直接复制就行了
2、Qt5.9.8 vs2017 :Tools > Options > C++ > Code Model > Clang Code Model > Manage
"Diagnostic Configuration" 默认选中的是 "Clang-only checks for almost everything [built-in]",然后 我将它 "Copy..."一下,名字命名为"Clang-only checks for almost everything (CopyByZC)"
于是 它现在的内容为:
-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
然后 再在 "Diagnostic Configuration"中选择 "Clang-only checks for almost everything (CopyByZC)"
3、后加的内容也记录下来,方便以后直接复制(而不用一直重复的手动一一敲入)
3.1、20191120 里面的内容为:
-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused -Wno-old-style-cast -Wno-sign-conversion -Wno-deprecated-declarations -Wno-reserved-id-macro -Wno-undef -Wno-reorder -Wno-cast-qual -Wno-nonportable-system-include-path -Wno-cast-align -Wno-zero-as-null-pointer-constant -Wno-microsoft-goto
3.2、20191127:
-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused -Wno-old-style-cast -Wno-sign-conversion -Wno-deprecated-declarations -Wno-reserved-id-macro -Wno-undef -Wno-reorder -Wno-cast-qual -Wno-nonportable-system-include-path -Wno-cast-align -Wno-zero-as-null-pointer-constant -Wno-microsoft-goto -Wno-format-nonliteral
------------------------------
一个 Code Mode 误报的例子
/* * Clang Code Model 的误报 * 编译器错误带有纯红色的点,代码模型错误带有带框的点 * * The project compiled and ran normally, even with the error * https://bugreports.qt.io/browse/QTCREATORBUG-22656 * * main.cpp:7:1: error: cannot initialize a parameter of type 'const char *' with an rvalue of type 'int' * qtest.h:446:5: note: expanded from macro 'QTEST_MAIN' * qtest.h:364:74: note: expanded from macro 'QTEST_SET_MAIN_SOURCE_PATH' * 16:30: note: expanded from here * qtestcase.h:302:75: note: passing argument to parameter 'builddir' here */
QTEST_MAIN(CommodityTest)
============ End