预编译的Clang无法看到Visual Studio头部

时间:2023-02-14 15:09:08

I'm new to Clang.

我是Clang的新手。

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

我已经用这篇文章开始编译预编译的Clang 3.5.0和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?

如何让预编译的Clang看到visual studio标题?

1 个解决方案

#1


1  

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

gmlacrosse是对的。我需要在命令行中添加include目录。

-I command line switch solves the problem:

-I命令行开关解决了这个问题:

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

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

#1


1  

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

gmlacrosse是对的。我需要在命令行中添加include目录。

-I command line switch solves the problem:

-I命令行开关解决了这个问题:

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

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