如何在编译时检测WP8 [英] How to detect WP8 at compilation time

查看:70
本文介绍了如何在编译时检测WP8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个跨平台的c ++库。我以WP8为目标,我需要检测目标是WP8还是Desktop Windows。

I'm developing a cross platform c++ library. I target WP8 among others and I need to detect if the target is WP8 or Desktop Windows.

是否为WP8目标自动设置了一个标志?

Is there a flag automatically set for WP8 targets?

我考虑过使用_WIN32,但无论如何似乎都定义了它。

I thought about using _WIN32 but it seems defined on both platforms anyway.

推荐答案

不确定这是否是您要查找的内容,但是如果您正在使用通用应用程序/便携式库,则可以使用

Not sure if this is what you're looking for but if you're doing a Universal App/Portable library you can detect it by using

C ++

来自winapifamily.h

From 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#


C#

#if WINDOWS_APP
// TODO
#endif

#if WINDOWS_PHONE_APP
// TODO
#endif

这篇关于如何在编译时检测WP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆