我想知道是否可以用clang解析GCC内置函数
int __builtin_ctz (unsigned int x)
,int __builtin_clz (unsigned int x)
。我想这样做的原因是,如果我尝试解析包含任何标准库的C ++文件,并使用正确的包含文件夹,则clang解析器代码无法解析使用内置函数的标准库文件。
以下是我配置C ++解析的方法:
/* CPP SUPPORT*/
clang::CompilerInvocation & invocation = toolset.getInvocation();
//Adjust for c++
auto& langOpts = toolset.getLangOpts();
langOpts.GNUMode = 1;
langOpts.GNUKeywords = 1;
langOpts.CXXExceptions = 1;
langOpts.RTTI = 1;
langOpts.Bool = 1;
langOpts.CPlusPlus11 = 1;
langOpts.CPlusPlus = 1;
langOpts.CXXOperatorNames = 1;
langOpts.WChar = 1;
langOpts.DeclSpecKeyword = 1;
clang::PreprocessorOptions &PPOpts = toolset.getPreprocessorOpts();
/* CPP SUPPORT*/
invocation.setLangDefaults(langOpts,
clang::InputKind::CXX,
llvm::Triple(targetConfig->Triple),
PPOpts,
clang::LangStandard::lang_cxx11);
我收到的错误是:
/usr/include/c++/5/bits/stl_algobase.h use of undeclared identifier '__builtin_clz'