1

I would like to create a common header file for my C/C++ files. In that header file I would like to have compile-time detection of which platform I'm building for and what type of application I'm building for that platform.

The options are:

  1. Desktop App. OS: Win 7 / Win 8.x. CPU: Intel/AMD. Device: PC/Laptop
  2. Windows Phone App. OS: Windows: 8.x. CPU: ARM. Device: Windows Mobile Phone
  3. Desktop App. OS: Windows 8.x. CPU: Intel. Device: Tablet
  4. Store App. OS: Windows 8.x. CPU: Intel. Device: Tablet
  5. Desktop App. OS: Windows RT. CPU: ARM. Device: Tablet
  6. Store App. OS: Windows RT. CPU: ARM. Device: Tablet

I'm not sure if [3] and [5] are actual possibilities.

I have looked at winapifamily.h but I'm not sure how to interpret (or understand) the partition table in that header file, so some help would be greatly appreciated.

In the header file I wish to create, I would like something like this:

#ifdef SOME_PREPROCESSOR_DEFINE
/* Option 1*/
#endif

#ifdef SOME_PREPROCESSOR_DEFINE
/* Option 2*/
#endif

#ifdef SOME_PREPROCESSOR_DEFINE
/* Option 3*/
#endif

#ifdef SOME_PREPROCESSOR_DEFINE
/* Option 4*/
#endif

#ifdef SOME_PREPROCESSOR_DEFINE
/* Option 5*/
#endif

#ifdef SOME_PREPROCESSOR_DEFINE
/* Option 6*/
#endif

Thank you.

user1884325
  • 2,530
  • 1
  • 30
  • 49

1 Answers1

2

Window versions are defined by a number of macros, see this link. You should be able to discriminate between different versions of windows by using these.

Other pre-defined macros for visual studio are listed here. Some combination of them should be able to help you. For example, _M_ARM is defined for an ARM processor.

thurizas
  • 2,473
  • 1
  • 14
  • 15