Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ clang astparser在分析的文件(未声明的标识符uu内置u swap32、va_列表等)中遇到stdlib问题_C++_Include_Clang_Std_Abstract Syntax Tree - Fatal编程技术网

C++ clang astparser在分析的文件(未声明的标识符uu内置u swap32、va_列表等)中遇到stdlib问题

C++ clang astparser在分析的文件(未声明的标识符uu内置u swap32、va_列表等)中遇到stdlib问题,c++,include,clang,std,abstract-syntax-tree,C++,Include,Clang,Std,Abstract Syntax Tree,我试图为一个大型c++项目编写一个astparser,该项目包含大量模板函数和结构,以及模板函子的用法。但是我现在被卡住了。第一个问题是我的astparser找不到stdlib.h。通过提供额外的系统依赖性,我解决了这个问题,包括到STDLIB h和其他系统和C++头的路径。但是,现在当我的解析器运行时,我会收到以下错误消息: In file included from source/real_test.cpp:2: In file included from /usr/include/c++/

我试图为一个大型c++项目编写一个astparser,该项目包含大量模板函数和结构,以及模板函子的用法。但是我现在被卡住了。第一个问题是我的astparser找不到stdlib.h。通过提供额外的系统依赖性,我解决了这个问题,包括到STDLIB h和其他系统和C++头的路径。但是,现在当我的解析器运行时,我会收到以下错误消息:

In file included from source/real_test.cpp:2:
In file included from /usr/include/c++/4.7.2/tr1/stdarg.h:32:
In file included from /usr/include/c++/4.7.2/tr1/cstdarg:32:
/usr/include/c++/4.7.2/cstdarg:56:11: error: no member named 'va_list' in the global namespace
using ::va_list;
    ~~^

/usr/include/bits/byteswap.h:47:10: error: use of undeclared identifier '__builtin_bswap32'<br>
return __builtin_bswap32 (__bsx);
     ^
/usr/include/bits/byteswap.h:111:10: error: use of undeclared identifier '__builtin_bswap64'
return __builtin_bswap64 (__bsx);
     ^


In file included from /usr/include/c++/4.7.2/fstream:40:
In file included from /usr/include/c++/4.7.2/istream:40:
In file included from /usr/include/c++/4.7.2/ios:39:
In file included from /usr/include/c++/4.7.2/iosfwd:42:
In file included from /usr/include/c++/4.7.2/bits/postypes.h:42:
In file included from /usr/include/c++/4.7.2/cwchar:46:
/usr/include/wchar.h:614:9: error: unknown type name '__gnuc_va_list'
                  __gnuc_va_list __arg)
                  ^
/usr/include/wchar.h:621:8: error: unknown type name '__gnuc_va_list'
                 __gnuc_va_list __arg)
                 ^
/usr/include/wchar.h:627:9: error: unknown type name '__gnuc_va_list'
                  __gnuc_va_list __arg)
                  ^
/usr/include/wchar.h:691:8: error: unknown type name '__gnuc_va_list'
                 __gnuc_va_list __arg)
                 ^
/usr/include/wchar.h:698:7: error: unknown type name '__gnuc_va_list'
                __gnuc_va_list __arg)
                ^
/usr/include/wchar.h:703:8: error: unknown type name '__gnuc_va_list'
                 __gnuc_va_list __arg)
等等

我不知道怎么解决它。我认为问题是,解析器知道它可以在哪里找到所需的C++头,它不包括定义宏的其他头,如前一个所需的谁能帮帮我吗

致以亲切的问候
Max

我猜您的astparser要么不包含通常由clang和/或GCC提供的内置函数,要么缺少通常由编译器设置的-D选项。你可以看到编译器使用的CLAN-E-DM XC/DEV/NULL定义的C++ C+、GCC和G++的相同的工作,使用C++ -STD=C++ 11或类似的toRoWielySuuBuffiT*是编译器提供的函数。您可以在clangsource目录的include/clang/Basic/Builtins.def中找到它们的列表。一个内置::Context在构造时传递给ASTContext。但是,假设这不是在你的情况下正确地做的……通过向另外的C++头提供额外的包含文件,ASPARSER不会像以前那样对任何未知类型的名称进行压缩。但是,我仍然有未声明的标识符uu builtin_bswap32/64、u builtin_clz、uu builtin_memcmp等等。以及分析项目的第一个translationunitdecl的转储,包含-TypedefDecl 0xa9c630 implicit _int128_t'_int128'等等。我想我的astparser确实遗漏了一些由-D选项提供的宏或一些进一步的内置函数。我将尝试使用您的建议在clang include目录中找到builtins.def:我已经定义了正确的BUILTIN:BUILTIN\u BUILTIN\u bswap16,UsUs,nc BUILTIN\u BUILTIN\u bswap32,UiUi,nc BUILTIN\u bswap64,ULLiULLi,ncYes,我希望builtins.def中包含所有内置项,但您的astparser似乎没有使用它们。对于某些内置类型也是如此。其中一些取决于您为之构建的目标,因此您可能需要考虑这一点。