c++ - 如何在编译时检测WP8

标签 c++ windows-phone-8 compilation

我正在开发一个跨平台的 C++ 库。我的目标是 WP8,我需要检测目标是 WP8 还是桌面 Windows。

是否有为 WP8 目标自动设置的标志?

我考虑过使用 _WIN32,但它似乎在两个平台上都有定义。

最佳答案

不确定这是否是您要查找的内容,但如果您正在做一个通用应用程序/可移植库,您可以使用

检测到它

C++

来自 winapifamily.h

/*
 * When compiling C and C++ code using SDK header files, the development
 * environment can specify a target platform by #define-ing the
 * pre-processor symbol WINAPI_FAMILY to one of the following values.
 * Each FAMILY value denotes an application family for which a different
 * subset of the total set of header-file-defined APIs are available.
 * Setting the WINAPI_FAMILY value will effectively hide from the
 * editing and compilation environments the existence of APIs that
 * are not applicable to the family of applications targeting a
 * specific platform.
 */

#define WINAPI_FAMILY_PC_APP      2     /* Windows Store Applications */
#define WINAPI_FAMILY_PHONE_APP   3     /* Windows Phone Applications */
#define WINAPI_FAMILY_DESKTOP_APP 100   /* Windows Desktop Applications */


// example usage
#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
// TODO:
#endif

C#

#if WINDOWS_APP
// TODO
#endif

#if WINDOWS_PHONE_APP
// TODO
#endif

关于c++ - 如何在编译时检测WP8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25573752/

相关文章:

c++ - 应该如何设置王朝?

python - Cython 可以编译成 EXE 吗?

c++ - 区分值模板类和左值模板类的正确特化是什么?

c++ - 可能的逻辑错误 : remove(vector. begin(),vector.end(),val)

c# - 为 WP8 平台构建原生 OpenSSL 库

c# - IronPython 编号 == null?

c++ - 如何同时处理一个 C++ 类的多个成员?

c++ - 为什么在进行 int/unsigned int 除法时使用 'divl'

javascript - Windows Phone 8 图像比视口(viewport)宽

c# - 如何编译包含 Access 数据库的 Visual C# 2008 程序?