clang 无法解析包含 libstdc++ 的源(gcc4.4)
我最近编译了新的 clang(现在为 3.1),并尝试使用它来解析我的项目,但是它在解析标准库/包含时失败...例如我看到以下错误:
/usr/include/c++/4.4/cstddef :51:9:错误:预期为“;”在顶级声明符之后 或者 /usr/include/c++/4.4/bits/cpp_type_traits.h:71:3: 错误:未知类型名称 'template'
显然 clang 无法解析此文件,但这些是标准 libstc 文件..我该怎么办?
i have recently compiled new clang(3.1 now), and tried to use it for parsing my project, however it fails at parsing standard libraries/includes... for example i see following errors:
/usr/include/c++/4.4/cstddef:51:9: error: expected ';' after top level declarator
or
/usr/include/c++/4.4/bits/cpp_type_traits.h:71:3: error: unknown type name 'template'
Obviously clang cannot parse this files, but these are standard libstc files ..what should i do with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我有自己的答案:
首先,我没有正确地介绍问题。我使用的是 libclang 库,而不是编译器本身。
其次,解决方案是在解析 C++ 代码时强制始终使用 C++ 语言,因为解析器本身有时会决定他正在解析 C 代码,即使它是 C++ 代码。
解决方案是将 -xc++ 参数传递给解析器。
Ok, i have my own answer:
First, i hadn't introduced properly the problem. I was using libclang library, not the compiler itself.
Second the solution is to force always c++ language, when you parse c++ code, since the parser itself sometimes decides, that he is parsing c code, even if its c++ code.
the solution is, to pass -xc++ argument to the parser.