[cfe-dev] how to build this program..

汶翰 (Wen-Han) nowar100 at gmail.com
Tue Jan 11 21:01:38 PST 2011


Hi,

If you want to use libclang.
Please include "clang-c/Index.h", and link with libclang.


2011/1/12 jignesh vasoya <jigneshvasoya at gmail.com>

> Hi,
> This program was given as an example by Mr. Gregor under the topic "
> libclang: Thinking Beyond the Compiler "
>
> int main(int argc, char *argv[])
> {
>     unsigned I;
>     CXIndex Index = clang_createIndex(0, 0);
>     CXTranslationUnit TU = clang_parseTranslationUnit(
> Index, 0,argv,
> argc, 0, 0, CXTranslationUnit_None);
>     CXTranslationUnit N;
>
>     for (I = 0, N = clang_getNumDiagnostics(TU); I != N; ++I)
>     {
>         CXDiagnostic Diag = clang_getDiagnostic(TU, I);
>         CXString String =
> clang_formatDiagnostic(Diag,clang_defaultDiagnosticDisplayOptions());
>         fprintf(stderr, "%s\n", clang_getCString(String));
>         clang_disposeString(String);
>     }
>
>     clang_disposeTranslationUnit(TU);
>     clang_disposeIndex(Index);
>
> return 0;
> }
>
>
> Can somebody tell me which headers i have to include?
> and how can i compile this program?
>
> i have installed llvm and clang (2.9) on my system.
>
> Thanks in advance.
> *
> ___________________________________________________________________________
> *
>
> -----------------------------------------------------------------------------------------------------------------------------
> *Jignesh Vasoya
> CSE - IIT MADRAS
> 9962248684*
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>


-- 
Best regards,
Wen-Han (Nowar)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110112/07daf3a8/attachment.html>


More information about the cfe-dev mailing list