[cfe-dev] How to tell the preprocessor where it can find its header files ?

Chris Hacking chacking at cs.washington.edu
Thu Feb 25 20:20:53 PST 2010


You need to modify the VS project file. If you'd created the project using
CMake this shouldn't have been a problem, but in any case.

 

It sounds like you may have, for whatever reason, told Visual Studio not to
use the standard includes (MSVC, the Microsoft Visual C++ compiler that VS
invokes internally, of course has a set of standard C/C++ libraries and
headers that it will use unless told not to).

 

Open the Project Properties

Under C/C++, find the Preprocessor page (I'm working from memory here; it
varies between versions but should be a page or tab or similar).

In the Preprocessor page, there will be an entry for something like "Use
standard Includes" {TRUE|FALSE}. Make sure this is set to TRUE.

You will also find an entry like "[Additional] Include Directories" or
similar, which will have a browse button. This is where you specify the
folders within the LLVM directory structure that contain header files.

Add here all of the .\include directories for LLVM/Clang (there's one right
inside the llvm directory, and there should be at least one more inside the
Clang directory).

 

Alternatively, you can invoke the compiler on the command line. The options
to do so in the MSVC are very much like those for GCC/Clang except I think
it uses / rather than - to indicate a command line switch. The properties
pages automatically generate these switches for you; for example /Iinclude
/Itools\clang\include .

 

In any case, using CMake is probably *far* easier. Not only do you not have
to mess with such things as include directories, it will automatically set
up the build order and other such useful tricks. In fact, some of the
clang/LLVM code is generated automatically, and it may be impossible to
compile LLVM/clang without running the scripts that generate it (which CMake
does automatically, after automatically determining what code needs to be
generated).

 

InitHeaderSearch.cpp is part of clang itself, making changes there will have
no effect until you successfully compile clang. I take it you've never
compiled a compiler before?

 

Chris

 

 

From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On
Behalf Of kalyan ponnala
Sent: Thursday, 25 February 2010 4:37 PM
To: cfe-dev at cs.uiuc.edu
Subject: [cfe-dev] How to tell the preprocessor where it can find its header
files ?

 

Hello,

I am using llvm/clang solution file generated by visual studio. When I say
-- "Clang-test"  -- > Set as Start-up Project -> build. I generates a bunch
of errors saying it cant find 
the include files stdio.h, stdlib.h, limits.h. Now how can I tell the
preprocessor where it can find its header files. Do I have to add some
commands to the visual studio or Do I have to change the helper class
"InitHeaderSearch" inside the InitHeaderSearch.cpp of the clangFrontend
target. If I have to modify the code then can an expert guide me through the
modifications that have to be made.

Thanks.

-- 
Kalyan Ponnala
phone: 8163772059

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100225/cdaa9224/attachment.html>


More information about the cfe-dev mailing list