#include "clang/Lex/PreprocessorOptions.h" #include "llvm/Support/CommandLine.h" int main(int argc, const char **argv) { clang::PreprocessorOptions PPOptions; llvm::cl::ParseCommandLineOptions(argc, argv, "clang preprocessor"); clang::LangOptions LangOpts; LangOpts = clang::getLangOptsFromCompilertInvocation(PPOptions, ""); if (LangOpts.CPlusPlus) std::cout << "C++ dialect is enabled\n"; return 0; }
#include "clang/Frontend/CompilerInstance.h" int main() { clang::CompilerInstance CI; clang::LangOptions &LO = CI.getPreprocessorOpts().getLangOpts(); if (!LO.CPlusPlus) std::cout << "C++ dialect is disabled\n"; return 0; }This example uses the getLangOptions function to check whether the C++ dialect option is enabled or disabled in the compiler instance. Package/Library: Clang C++ preprocessor