I'm trying to parse a library using libclang, and I'm stuck with what could be a very simple issue: how to configure it with STL?
At the moment, it fails to parse a translation unit because it can't find <string>
.
Here's what I tried :
char *args[] = {"-x", "c++", "-Ic:/my/library/includes", "-IG:/Prog/libcxx-3.4/include"};
clang_parseTranslationUnit(index, "c:/my/library/test.cpp", args, 4, 0, 0, 0);
I'm on windows, with the precompiled clang binaries downloaded from llvm.org, and I tried with various STL implementations :
- Visual studio
- MingW
- libCXX
In each case, I ended up with unknown types.
For example, with mingw, I've got the following error messages :
/mingw/include\wchar.h:221:71: error: unknown type name '_locale_t'
/mingw/include\wchar.h:223:81: error: unknown type name '_locale_t'
/mingw/include\stdlib.h:173:65: error: unknown type name '_locale_t'
/mingw/include\stdlib.h:175:75: error: unknown type name '_locale_t'
/mingw/include\io.h:301:14: error: unknown type name 'off64_t'
/mingw/include\io.h:301:36: error: C++ requires a type specifier for all declarations
/mingw/include\io.h:302:14: error: unknown type name 'off64_t'
/mingw/include\io.h:302:39: error: unknown type name 'off64_t'
/mingw/include\unistd.h:65:20: error: unknown type name 'off_t'
The rare tutorials I've found about this subject don't talk about this subject...