Either your adding the "-x c++"-option to your compilercreateion, or, by code, you can take the language-options of the compiler and set the appropriate flags by yourself<br>LangOptions lopts= compiler.getLangOptions(); (<a href="http://clang.llvm.org/doxygen/classclang_1_1LangOptions.html">http://clang.llvm.org/doxygen/classclang_1_1LangOptions.html</a>)<br>
<br><div class="gmail_quote">2011/6/22 Adam Smalin <span dir="ltr"><<a href="mailto:acidzombie24@gmail.com">acidzombie24@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
using this dummy source file<br><br>struct AA {<br>    int a, b, c;<br>    void ff(int z){ }<br>};<br>void funcAZ() {}<br>int main(){<br>    struct AA aa;<br>    int a=1;<br>}<br><br>I ran the code at the end of this email. there are no cmd line arguments and the file is a.cpp.<br>

<br>When it runs my ASTConsumer i get the assert error<br><br>Unexpected diagnostic outside source file processing<br><br>however if i remove the ff function in AA, it runs fine. I assume the problem is the compiler is running in c mode and i am using c++ source.<br>

How do i tell it to compile in C++ mode?<br><br><br>    CompilerInstance compiler;<br>    <br>    compiler.createDiagnostics(argc, argv);<br>    CompilerInvocation::CreateFromArgs( compiler.getInvocation(),<br>    argv + 1, argv + argc, compiler.getDiagnostics() );<br>

    <br>    compiler.setTarget( TargetInfo::CreateTargetInfo(<br>    compiler.getDiagnostics(), compiler.getTargetOpts() ) );<br>    <br>    compiler.createFileManager();<br>    compiler.createSourceManager(compiler.getFileManager());<br>

    compiler.createPreprocessor();<br>    compiler.createASTContext();<br>    compiler.setASTConsumer( new PrintFunctionsConsumer);<br>    <br>    compiler.createSema(false, NULL);<br>    <br>    <br>    compiler.InitializeSourceManager( main_input_file );<br>

    ParseAST( compiler.getPreprocessor(), &compiler.getASTConsumer(), compiler.getASTContext() );<br><div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>