【发布时间】:2010-06-18 23:09:58
【问题描述】:
这是我十多年来第一次摆弄 Windows 世界,所以这可能是一个简单的解决方法。但我完全被卡住了。
假设你有一个源目录,
mkdir helloworld && touch helloworld/helloworld.{h.cpp}
helloworld.cpp:
#include "helloworld.h"
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
}
helloworld.h:
#include <iostream>
现在你有一个如下所示的编译命令:
cl.exe helloworld/helloworld.cpp
我对标准行为的理解是预处理器对引用的查找包括外观
- 在源文件同一目录下
- 以前打开的文件
- cli 指定 -I 包含路径
- 在 INCLUDE 环境中找到的路径
现在,这显然属于第一类,但我总是得到:
Z:\Projects\temp>cl helloworld\helloworld.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
helloworld.cpp
helloworld\helloworld.cpp(1) : fatal error C1083: Cannot open include file: 'helloworld.h': No such file or directory
所以,当我输入此内容时,我突然想到......“如果是因为我的项目位于共享文件系统上怎么办?”。
我将同一个项目复制到 C:\,它编译得很好!
有人知道这里发生了什么吗?
【问题讨论】:
-
顺便说一句,standard 行为(如在 ISO 标准中)没有这样的说法。定位包含文件完全依赖于实现。
标签: visual-studio-2010 windows-7