For the question raised in the below link, clang getting include files while parsing AST
对于以下链接所提出的问题,clang在解析AST时包含文件。
I used the 'parsing example file' for my input file with my system specific header paths, but I get errors for 'ptrdiff_t', 'size_t', 'wchar_t' types not defined.
我使用了我的系统特定的标题路径的输入文件的“解析示例文件”,但是我得到了“ptrdiff_t”、“size_t”、“wchar_t”类型的错误。
I am using below header path:
我在标题路径下使用:
/usr/include /usr/include/bits /usr/include/linux /usr/include/c++/4.1.2 /usr/include/c++/4.1.2/bits /usr/include/c++/4.1.2/tr1 /usr/include/c++/4.1.2/i386-redhat-linux/bits /usr/include/c++/4.1.2/i386-redhat-linux /usr/include/c++/4.1.2/i386-redhat-linux/tr1
Additionally I have also added following, for specifying that the input is c++. These variables are default set to 0 in LangOptions.h
此外,我还添加了以下内容,用于指定输入是c++。这些变量在LangOptions.h中默认设置为0。
languageOptions.CPlusPlus = 1;//// C++ Support
languageOptions.Bool = 1; //// 'bool', 'true', 'false' keywords.
languageOptions.CXXOperatorNames =1;//// Treat C++ operator names as keywords
The errors I get are listed below. Any help to resolve this is appreciated.
我得到的错误列在下面。任何帮助解决这个问题都是值得赞赏的。
In file included from /home/p/expl1.cpp:12:
In file included from /usr/include/c++/4.1.2/string:46:
In file included from /usr/include/c++/4.1.2/bits/char_traits.h:45:
In file included from /usr/include/c++/4.1.2/cstring:50:
/usr/include/c++/4.1.2/cstddef:54:11: error: no member named 'ptrdiff_t' in the global namespace
using ::ptrdiff_t;
~~^
In file included from /usr/include/c++/4.1.2/string:46:
In file included from /usr/include/c++/4.1.2/bits/char_traits.h:45:
In file included from /usr/include/c++/4.1.2/cstring:52:
/usr/include/string.h:39:40: error: unknown type name 'size_t'
__const void *__restrict __src, size_t __n)
^
/usr/include/string.h:43:58: error: unknown type name 'size_t'
extern void *memmove (void *__dest, __const void *__src, size_t __n)
^
/usr/include/string.h:52:18: error: unknown type name 'size_t'
int __c, size_t __n)
^
/usr/include/string.h:59:42: error: unknown type name 'size_t'
/usr/include/c++/4.1.2/bits/stringfwd.h:63:33: error: use of undeclared identifier 'wchar_t'
template<> struct char_traits<wchar_t>;
I observe that these should be defined in stddef.h, but my stddef.h in /usr/include/linux/stddef.h has
我观察到这些应该在stddef中定义。h,但我stddef。h /usr/include/linux/stddef.h已经
#ifndef _LINUX_STDDEF_H
#define _LINUX_STDDEF_H
#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
Thanks for any help in advance.
谢谢你的帮助。
Is it possible to disable clang from generating diagnostics related to system header files.? I couldn't find any way to do this, as I don't think there is any direct way to do this.
是否可以禁用clang来生成与系统头文件相关的诊断?我找不到任何方法来做这件事,因为我不认为有任何直接的方法可以做到这一点。
1 个解决方案
#1
1
While interop between Clang and GCC is possible to some extent, some standard library headers are extremely compiler-dependent. In fact, stddef.h and stdarg.h are produced along with Clang when you build it. They are considered "built-in includes". It is very possible that you won't be able to get it to work properly if you don't have them.
虽然Clang和GCC之间的互操作在某种程度上是可能的,但是一些标准的库头是非常依赖于编译器的。事实上,stddef。h和stdarg。当你建造它的时候,h和Clang一起产生。它们被认为是“内置的”。如果你没有的话,你很有可能无法让它正常工作。
The good news is that if you have the Clang driver, you probably have the headers too. As they mention on the website, Clang looks for these headers in $(path/to/tool)/../lib/clang/3.3/include
.
好消息是,如果你有Clang驱动程序,你可能也有header。正如他们在网站上所提到的,Clang寻找这些标题的$(path/to/tool)/. /lib/ Clang /3.3/include。
#1
1
While interop between Clang and GCC is possible to some extent, some standard library headers are extremely compiler-dependent. In fact, stddef.h and stdarg.h are produced along with Clang when you build it. They are considered "built-in includes". It is very possible that you won't be able to get it to work properly if you don't have them.
虽然Clang和GCC之间的互操作在某种程度上是可能的,但是一些标准的库头是非常依赖于编译器的。事实上,stddef。h和stdarg。当你建造它的时候,h和Clang一起产生。它们被认为是“内置的”。如果你没有的话,你很有可能无法让它正常工作。
The good news is that if you have the Clang driver, you probably have the headers too. As they mention on the website, Clang looks for these headers in $(path/to/tool)/../lib/clang/3.3/include
.
好消息是,如果你有Clang驱动程序,你可能也有header。正如他们在网站上所提到的,Clang寻找这些标题的$(path/to/tool)/. /lib/ Clang /3.3/include。