2

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.

Eric
  • 19,525
  • 19
  • 84
  • 147

1 Answers1

1

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
Chubosaurus Software
  • 8,133
  • 2
  • 20
  • 26
  • 1
    This looked promising but winapifamily.h doesn't seem to exist on all my systems. I have VS2012 on another win32 computer which can't find it – Eric Sep 01 '14 at 17:12