#error你必须定义平台宏

时间:2012-08-20 12:27:28

标签: c++ macros cross-platform c-preprocessor

我有一个我编译的项目,它给了我以下错误:

In file included from c:/acrobatxsdk/Adobe/Acrobat 10 SDK/Version 1/PluginSupport/Headers/API/PIMain.c:21:0:
c:/acrobatxsdk/Adobe/Acrobat 10 SDK/Version 1/PluginSupport/Headers/API/Environ.h:37:2: error: #error You must define the PLATFORM macro
c:/acrobatxsdk/Adobe/Acrobat 10 SDK/Version 1/PluginSupport/Headers/API/Environ.h:41:10: error: #include expects "FILENAME" or <FILENAME>
c:/acrobatxsdk/Adobe/Acrobat 10 SDK/Version 1/PluginSupport/Headers/API/Environ.h:52:2: error: #error PLATFORM failed to #define ACCB1

PIMain.c如下所示:

#if WIN_PLATFORM
#include "WinCalls.h"
#elif MAC_PLATFORM
#include "MacCalls.h"
#elif UNIX_PLATFORM
#include "UnixCalls.h"
#else
#error platform not defined
#endif

我已经知道,如果需要,唯一的修改是在Environ.h中进行,有人可以提出建议吗?

1 个答案:

答案 0 :(得分:0)

Environ.h正在查找PLATFORM指令,并且如果您没有定义错误,则会有一个预处理器或编译时标志来“抛出”错误。了解#error指令在(MSDN link)的工作原理。

我找到了Environ.h的代码:

#ifndef PLATFORM
#ifdef WIN_ENV
#define PLATFORM "winpltfm.h"
#elif __OS2__
#define PLATFORM "os2pltfm.h"
#elif defined(unix) || defined(__unix)
 #define PLATFORM "UnixPlatform.h"
#else
#error You must define the PLATFORM macro
#endif
#endif

您显然没有在受支持的平台上运行。