Search code examples
c++visual-studio-2012clangheader-files

Pre-compiled Clang can't see the Visual Studio headers


I'm new to Clang.

I've used this article to get started with pre-compiled Clang 3.5.0 and Visual Studio 2012.

When i tried to compile the following code:

// hello.c
#include <stdio.h>

int main() {
    printf("hello world\n");
    return 0;
}

like this

C:\..> clang -c hello.c -emit-llvm -o hello.bc

i got an error:

hello.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.

How do i make pre-compiled Clang see the visual studio headers?


Solution

  • gmlacrosse was right. I need to add include directory to the command line.

    -I command line switch solves the problem:

    C:\..> clang -c hello.c -emit-llvm -o hello.bc -I "c:\Program Files\Microsoft Visual Studio 11.0\VC\include"