[cfe-dev] libclang question

Benjamin Kramer benny.kra at googlemail.com
Sun Dec 5 02:37:41 PST 2010


On 05.12.2010, at 10:23, jiyang zhao wrote:

> hi you guys
> I just spent some time on libclang, and wrote a test programme, but i met some problems. 

> When I ran the programme on a .h file,  i got the following results:
> 
> Diag: ../ckit/ckit_comm.h:28:1: error: unknown type name 'bool'
> Diag: ../ckit/ckit_comm.h:32:1: error: unknown type name 'bool'
> Diag: ../ckit/ckit_comm.h:43:1: error: unknown type name 'bool'
> Diag: ../ckit/ckit_comm.h:51:5: error: conflicting types for 'createTranslationUnit'
> Diag: ../ckit/ckit_comm.h:47:5: note: previous declaration is here

clang can't tell if a .h file contains C or C++ so it defaults to C. You have to
specify the file type on the command line with the -x flag if you want to analyze
a C++ header.

$ clang-test -x c++-header ckit_comm.h

When you use the .hpp extension clang knows that it's a C++ header.



More information about the cfe-dev mailing list