[cfe-dev] clang include problems

Marc Michael mmichael at informatik.uni-bremen.de
Tue Jun 26 01:02:44 PDT 2012


I tried to compile and run the tutorials from 
https://github.com/loarabia/Clang-tutorial.

The first problem was a not working makefile. The makefile uses 
‘llvm-config –cxxflags’ which produces the following:

-I/local/home/me/svn/llvm/llvm/include 
-I/local/home/me/svn/llvm/build/include  -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -

After I manually added the following path I could compile the examples:

-I/local/home/me/svn/llvm/build/tools/clang/include
-I/local/home/me/svn/llvm/llvm/tools/clang/include

Was this a wrong use of llvm-config or are the paths really incorrect?

In tutorial4.cpp 
(https://github.com/loarabia/Clang-tutorial/blob/9af14578d6342f07d7529447a2193b7946a1cf3a/CItutorial4.cpp) 
I manually added the following path code:
     headerSearchOptions.AddPath("/usr/include",
             clang::frontend::Angled,
             false,
             false,
             false);
     headerSearchOptions.AddPath("/usr/include/linux",
             clang::frontend::Angled,
             false,
             false,
             false);
     headerSearchOptions.AddPath("/usr/include/c++/4.4.4/tr1",
             clang::frontend::Angled,
             false,
             false,
             false);
 
headerSearchOptions.AddPath("/usr/include/c++/4.4.4/x86_64-redhat-linux",
             clang::frontend::Angled,
             false,
             false,
             false);
     headerSearchOptions.AddPath("/usr/include/c++/4.4.4",
             clang::frontend::Angled,
             false,
             false,
             false);

Are these paths correct (I am using Fedora 15)? Are all of them 
necessary? When I try to run tutorial4 I get the following error:

./tutorial4 testInclude.c
In file included from testInclude.c:1:
In file included from /usr/include/stdio.h:75:
/usr/include/libio.h:332:3: error: unknown type name 'size_t'
   size_t __pad5;
   ^
/usr/include/libio.h:336:67: error: use of undeclared identifier 
'size_t'; did you mean 'sizeof'?
   char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
                                                                   ^
/usr/include/libio.h:364:62: error: unknown type name 'size_t'
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t 
__nbytes);
                                                              ^
/usr/include/libio.h:373:6: error: unknown type name 'size_t'
                                  size_t __n);
                                  ^
/usr/include/libio.h:491:4: warning: declaration specifier missing, 
defaulting to 'int'
                         _IO_va_list, int *__restrict);
                         ^~~~~~~~~~~
                         int
/usr/include/libio.h:47:21: note: expanded from macro '_IO_va_list'
#define _IO_va_list _G_va_list
                     ^
/usr/include/_G_config.h:66:20: note: expanded from macro '_G_va_list'
#define _G_va_list __gnuc_va_list
                    ^~~~~~~~~~~~~~


After searching throw the internet I found 
(http://clang-developers.42468.n3.nabble.com/unable-to-parse-header-files-td2145004.html) 
the following advice. I should add the following line:
headerSearchOptions.ResourceDir = LLVM_PREFIX "/lib/clang/" 
CLANG_VERSION_STRING;
But this does not solve my problem. LLVM_PREFIX is not declared. I tried 
to define the hole string by myself:
headerSearchOptions.ResourceDir = 
"/local/home/me/svn/llvm/build/Debug+Asserts/lib/clang/3.2/lib/linux";
It didn’t help. Is this path even correct?

Thanks for your help!



More information about the cfe-dev mailing list