【发布时间】:2018-10-25 15:00:51
【问题描述】:
我在开发中使用 clang-tidy 作为“linter”工具。我开始将第 3 方软件集成到我的代码中,当我使用以下方法包含他们的头文件时:
-I/path/to/include
产生了大量错误,我什至还没有#include 标头。
error: too many errors emitted, stopping now [clang-diagnostic-error]
...
/path/to/include/wchar.h:81:1: error: unknown type name 'wint_t' [clang-diagnostic-error]
wint_t fgetwc(FILE *__stream);
^
/path/to/include/wchar.h:81:15: error: unknown type name 'FILE' [clang-diagnostic-error]
wint_t fgetwc(FILE *__stream);
^
...
我使用以下代码编译我的程序:
/usr/bin/clang-tidy-4.0 /path/to/main.cpp -checks=-*,cppcoreguidelines* -- -lang-c++ -I/path/to/include -std=gnu++11 -Wall -Werror -O0 -g -D<define variables>
似乎这些“clang-diagnostic-errors”并没有停止编译,因为它继续编译并且运行良好。是否有标志可以关闭/抑制此错误?我不想看,因为我没有写这些头文件。
如果我去掉-I/path/to/include 的参数,一切都可以正常编译,没有错误。
【问题讨论】:
-
我已经成功使用
-header-filter。 Docs -
-header-filter不让 clang-tidy 检查那些头文件吗?我根本不想检查它们,我认为这是默认设置? -
是的,默认情况下它应该忽略所有标题,尽管我只熟悉较新的版本。也许当直接传递 -I 时,它的行为与使用
compile-commands.json不同? -
clang-diagnostic-error好像很特别,不是定期检查。标题过滤对我也不起作用。
标签: c++ header-files linter clang-tidy