How to detect WP8 at compilation time

2019-05-23 20:50发布

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.

Is there a flag automatically set for WP8 targets?

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

1条回答
可以哭但决不认输i
2楼-- · 2019-05-23 21:33

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++

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#

#if WINDOWS_APP
// TODO
#endif

#if WINDOWS_PHONE_APP
// TODO
#endif
查看更多
登录 后发表回答