【发布时间】:2017-12-11 10:55:52
【问题描述】:
如果为单个 cpp 文件(即不是整个项目)设置了 /Yu,是否可以设置 /FI 以指定要包含的头文件或必须包含头文件,例如 @987654325 @如果/Yu"stdafx.h"传递给CL?
以下所有导致基本相同的错误...
在C:\path\to\stdafx.h 和test.cpp 有一个标题,就像这样......
// Not including `stdafx.h`
void foo() {}
其中任何一个要编译...
CL.exe /c /Yu"stdafx.h" /FI"C:\path\to\stdafx.h" test.cpp
CL.exe /c /Yu /FI"C:\path\to\stdafx.h" test.cpp
CL.exe /c /Yustdafx.h /FIC:\path\to\stdafx.h test.cpp
CL.exe /c /Yu /FIC:\path\to\stdafx.h test.cpp
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
在我看来应该可以使用/FI来指定预编译的头文件。
这个答案似乎表明它甚至是首选方法 https://stackoverflow.com/a/11052390/6225135
【问题讨论】:
-
更多表明它有效的答案:stackoverflow.com/a/11403418/15416。 @VTT:
/FI被描述为隐含的#include -
问题可能出在
stdafx.h不是C:\path\to\stdafx.h吗? IOW,问题可能是 VC++ 进行字符串比较,而不是尝试确定两个名称是否引用同一个文件。 -
是的,就是这样,@MSalters 我有
/Yu"stdafx.h"和/FI"C:\full\path\to\stdafx.h",这是一个禁忌,即使它们是等价的,它们也必须是相同的。如果您回复,我将接受它作为答案。谢谢!
标签: c++ visual-c++ precompiled-headers