小编kyu*_*yue的帖子

为什么我不能#ifdef stdafx.h?

我试图在我的.cpp文件中包含2个特定于平台的stdafx.h文件,但是当我尝试#ifdef时编译器不满意.

#ifdef _WIN32
#include "stdafx.h"
#elif _MAC
#include "MAC/stdafx.h"
#endif
Run Code Online (Sandbox Code Playgroud)

您可能想知道为什么我在Mac代码中使用stdafx.h,但目前并不重要:).

当我尝试在Windows上编译代码时,我收到:致命错误C1018.我尝试用#ifdef将其他头文件封装在同一个文件中,编译器很高兴.因此,看起来Windows不喜欢stdafx.h是#ifdef-ed,或者Windows只允许#include stdafx.h 成为文件中的第一行.

所以我的问题是,为什么?

conditional-compilation stdafx.h

11
推荐指数
2
解决办法
2908
查看次数

标签 统计

conditional-compilation ×1

stdafx.h ×1