如果/Yu
为单个cpp文件设置了if (即不是为整个项目设置),则可以设置/FI
为指定要包含的头文件,还是必须将头文件包含在其中(例如,#include "stdafx.h"
如果/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
问题stdafx.h
是不是C:\path\to\stdafx.h
。VC ++进行字符串比较。您需要添加C:\path\to\
到包含路径,因此您可以使用/FI"stdafx.h"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句