[cfe-dev] unable to parse header files
Peter Collingbourne
peter at pcc.me.uk
Sat Dec 25 13:00:14 PST 2010
Hi Alex,
On Sat, Dec 25, 2010 at 01:13:42PM +0100, Alexander Christ wrote:
> /usr/include/c++/4.4/cstddef:50:11: error: no member named 'ptrdiff_t' in
> the global namespace
> using ::ptrdiff_t;
> ~~^
> /usr/include/c++/4.4/cstddef:51:11: error: no member named 'size_t' in the
> global namespace
> using ::size_t;
> ~~^
You need to set HeaderSearchOptions::ResourceDir so that Clang can
find its own header files including stddef.h. It's proably picking
up another stddef.h here which does not define the symbols correctly.
Something like this (CLANG_VERSION_STRING is defined by the header
but you need to define LLVM_PREFIX yourself, which is the LLVM/Clang
installation prefix):
#include "clang/Basic/Version.h"
...
headerSearchOptions.ResourceDir = LLVM_PREFIX "/lib/clang/" CLANG_VERSION_STRING;
> In file included from test.cpp:2:
> In file included from /usr/include/c++/4.4/map:59:
> In file included from /usr/include/c++/4.4/bits/stl_tree.h:62:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:63:
> /usr/include/c++/4.4/bits/cpp_type_traits.h:80:12: error: unknown type name
> 'bool'
> template<bool>
> ^
> /usr/include/c++/4.4/bits/cpp_type_traits.h:85:25: error: use of undeclared
> identifier 'true'
> struct __truth_type<true>
>From your code:
> languageOptions.CPlusPlus= 1;
You need to set other language options for C++, including
LangOptions::Bool. You can set all the correct language options
automatically using CompilerInvocation::setLangDefaults:
CompilerInvocation::setLangDefaults(languageOptions, IK_CXX);
Thanks,
--
Peter
More information about the cfe-dev
mailing list