how to build this program..

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to build this program..

jignesh vasoya
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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: how to build this program..

汶翰 (Wen-Han)
Hi,

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


2011/1/12 jignesh vasoya <[hidden email]>
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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




--
Best regards,
Wen-Han (Nowar)

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev