使用Clang工具解析c++标准头文件时出错
Error using Clang tool to parse a C++ standard header file
我使用clang工具解析位于/usr/lib/gcc/x86_64-linux-gnu/4.7/string的标准头文件。但是我得到以下错误:
In file included from ~/PrototypeWork/user/header.hpp:3:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/string:41:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/char_traits.h:41:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/postypes.h:41:
/usr/include/c++/4.7/tr1/cwchar:42:14: error: no member named 'wcstof' in namespace 'std'
using std::wcstof;
~~~~~^
/usr/include/c++/4.7/tr1/cwchar:45:14: error: no member named 'vfwscanf' in namespace 'std'
using std::vfwscanf;
~~~~~^
问题似乎是clang将字符串头读取为C头而不是c++头,因此它无法解析"using"关键字。因此,我继续添加了-TP命令行选项,该选项表示将所有源文件视为c++,但这没有帮助。
在使用-TP命令行选项
后,我得到以下警告warning: argument unused during compilation: '-T P'
有人能帮我解决这个问题吗?Clang命令行选项:http://clang.llvm.org/docs/UsersManual.html#id5
代码我的主要函数有这些:
int main() {
std::vector<std::string> cmdLine = boost::assign::list_of
("-TP")
("-I/usr/include")
("-I/usr/include/c++/4.7/tr1/");
clang::tooling::FixedCompilationDatabase db(".",cmdLine);
// Provide clang with the header file that needs to be parsed
// Run the clang tool .
}
抱歉,如果这是一个"谢谢你,显而易见的船长"的回答,但是:是否有可能,被解析的代码只是失败的#include <cwchar>
?默认情况下,clang
比gcc
更严格一些,因此,如果未能包含声明函数的头文件,则会看到如下错误:
相关文章:
- 读取文件的最后一行并输入到链接列表时出错
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- .h 和.cpp文件分离时出错,但仅使用 .h 文件时没有错误.我做错了什么?
- 在 C/C++ 中打开驻留在 "/sys/" 下的文件时出错
- 在头文件中定义变量不会出错
- 如何在多写入器情况下对文件支持的共享内存中的大页面出错
- JNI,使用两个 .so 文件时出错,其中一个文件需要另一个文件
- 生成文件中隐式规则中的 -c 标志出错
- 编译时出错 - 链接.cpp和头文件
- 从人员矢量插入和读取文件时出错
- LNK2019 在文件中调用静态成员的方法时出错.cpp
- ./main:加载共享库时出错:libopencv_highgui.so.4.0:无法打开共享对象文件:没有这样的文件或
- 猫鼬 - 包含标准C++库文件时出错
- 在f2c.h文件中定义min()max()宏时出错
- ASIOSDK;从hostsample.cpp生成mex文件时出错
- 使用emscripten将c++文件转换为wasm时出错
- 编译后可执行文件出错
- 头文件C++出错
- ftell 非常大的文件出错
- 从磁盘读取映像文件出错