我试图在我的 .cpp 文件中包含 2 个特定于平台的 stdafx.h 文件,但是当我尝试使用 #ifdef 时,编译器不满意。
#ifdef _WIN32
#include "stdafx.h"
#elif _MAC
#include "MAC/stdafx.h"
#endif
你可能会想知道我在 Mac 代码中为什么使用 stdafx.h,但这并不重要 :)
当我尝试在 Windows 上编译代码时,我收到了致命错误 C1018。我尝试在同一文件中使用 #ifdef 把其他头文件括起来,编译器很开心。因此,看起来 Windows 不喜欢将 stdafx.h 使用 #ifdef 进行处理,或者说 Windows 只允许 #include stdafx.h 是文件的第一行。
所以我的问题是,为什么呢?
Kat