winapifamily.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. winapifamily.h
  5. Abstract:
  6. Master include file for API family partitioning.
  7. */
  8. #ifndef _INC_WINAPIFAMILY
  9. #define _INC_WINAPIFAMILY
  10. #if defined(_MSC_VER) && !defined(MOFCOMP_PASS)
  11. #if _MSC_VER >= 1200
  12. #pragma warning(push)
  13. #pragma warning(disable:4001) /* nonstandard extension 'single line comment' was used */
  14. #endif
  15. #pragma once
  16. #endif // defined(_MSC_VER) && !defined(MOFCOMP_PASS)
  17. #include <winpackagefamily.h>
  18. /*
  19. * When compiling C and C++ code using SDK header files, the development
  20. * environment can specify a target platform by #define-ing the
  21. * pre-processor symbol WINAPI_FAMILY to one of the following values.
  22. * Each FAMILY value denotes an application family for which a different
  23. * subset of the total set of header-file-defined APIs are available.
  24. * Setting the WINAPI_FAMILY value will effectively hide from the
  25. * editing and compilation environments the existence of APIs that
  26. * are not applicable to the family of applications targeting a
  27. * specific platform.
  28. */
  29. /* In Windows 10, WINAPI_PARTITIONs will be used to add additional
  30. * device specific APIs to a particular WINAPI_FAMILY.
  31. * For example, when writing Windows Universal apps, specifying
  32. * WINAPI_FAMILY_APP will hide phone APIs from compilation.
  33. * However, specifying WINAPI_PARTITION_PHONE_APP=1 additionally, will
  34. * unhide any API hidden behind the partition, to the compiler.
  35. * The following partitions are currently defined:
  36. * WINAPI_PARTITION_DESKTOP // usable for Desktop Win32 apps (but not store apps)
  37. * WINAPI_PARTITION_APP // usable for Windows Universal store apps
  38. * WINAPI_PARTITION_PC_APP // specific to Desktop-only store apps
  39. * WINAPI_PARTITION_PHONE_APP // specific to Phone-only store apps
  40. * WINAPI_PARTITION_SYSTEM // specific to System applications
  41. * The following partitions are indirect partitions and defined in
  42. * winpackagefamily.h. These partitions are related to package based
  43. * partitions. For example, specifying WINAPI_PARTITION_SERVER=1 will light up
  44. * any API hidden behind the package based partitions that are bound to
  45. * WINAPI_PARTITION_SERVER, to the compiler.
  46. * WINAPI_PARTITION_SERVER // specific to Server applications
  47. */
  48. /*
  49. * The WINAPI_FAMILY values of 0 and 1 are reserved to ensure that
  50. * an error will occur if WINAPI_FAMILY is set to any
  51. * WINAPI_PARTITION value (which must be 0 or 1, see below).
  52. */
  53. #define WINAPI_FAMILY_PC_APP 2 /* Windows Store Applications */
  54. #define WINAPI_FAMILY_PHONE_APP 3 /* Windows Phone Applications */
  55. #define WINAPI_FAMILY_SYSTEM 4 /* Windows Drivers and Tools */
  56. #define WINAPI_FAMILY_SERVER 5 /* Windows Server Applications */
  57. #define WINAPI_FAMILY_DESKTOP_APP 100 /* Windows Desktop Applications */
  58. /* The value of WINAPI_FAMILY_DESKTOP_APP may change in future SDKs. */
  59. /* Additional WINAPI_FAMILY values may be defined in future SDKs. */
  60. /*
  61. * For compatibility with Windows 8 header files, the following
  62. * synonym for WINAPI_FAMILY_PC_APP is temporarily #define'd.
  63. * Use of this symbol should be considered deprecated.
  64. */
  65. #define WINAPI_FAMILY_APP WINAPI_FAMILY_PC_APP
  66. /*
  67. * If no WINAPI_FAMILY value is specified, then all APIs available to
  68. * Windows desktop applications are exposed.
  69. */
  70. #ifndef WINAPI_FAMILY
  71. #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
  72. #endif
  73. /*
  74. * API PARTITONs are part of an indirection mechanism for mapping between
  75. * individual APIs and the FAMILYs to which they apply.
  76. * Each PARTITION is a category or subset of named APIs. PARTITIONs
  77. * are permitted to have overlapping membership -- some single API
  78. * might be part of more than one PARTITION. PARTITIONS are each #define-ed
  79. * to be either 1 or 0 or depending on the platform at which the app is targeted.
  80. */
  81. /*
  82. * The mapping between families and partitions is summarized here.
  83. * An X indicates that the given partition is active for the given
  84. * platform/family.
  85. *
  86. * +-------------------+---+
  87. * | *Partition* | |
  88. * +---+---+---+---+---+---+
  89. * | | | | | | |
  90. * | | | | | | |
  91. * | | | | P | | |
  92. * | | | | H | | |
  93. * | D | | | O | | |
  94. * | E | | P | N | S | S |
  95. * | S | | C | E | Y | E |
  96. * | K | | _ | _ | S | R |
  97. * | T | A | A | A | T | V |
  98. * +-------------------------+----+ O | P | P | P | E | E |
  99. * | *Platform/Family* \| P | P | P | P | M | R |
  100. * +------------------------------+---+---+---+---+---+---+
  101. * | WINAPI_FAMILY_DESKTOP_APP | X | X | X | | | |
  102. * +------------------------------+---+---+---+---+---+---+
  103. * | WINAPI_FAMILY_PC_APP | | X | X | | | |
  104. * +------------------------------+---+---+---+---+---+---+
  105. * | WINAPI_FAMILY_PHONE_APP | | X | | X | | |
  106. * +----------------------------- +---+---+---+---+---+---+
  107. * | WINAPI_FAMILY_SYSTEM | | | | | X | |
  108. * +----------------------------- +---+---+---+---+---+---+
  109. * | WINAPI_FAMILY_SERVER | | | | | X | X |
  110. * +------------------------------+---+---+---+---+---+---+
  111. *
  112. * The table above is encoded in the following expressions,
  113. * each of which evaluates to 1 or 0.
  114. *
  115. * Whenever a new family is added, all of these expressions
  116. * need to be reconsidered.
  117. */
  118. #if WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP && \
  119. WINAPI_FAMILY != WINAPI_FAMILY_PC_APP && \
  120. WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP && \
  121. WINAPI_FAMILY != WINAPI_FAMILY_SYSTEM && \
  122. WINAPI_FAMILY != WINAPI_FAMILY_SERVER
  123. #error Unknown WINAPI_FAMILY value. Was it defined in terms of a WINAPI_PARTITION_* value?
  124. #endif
  125. #ifndef WINAPI_PARTITION_DESKTOP
  126. #define WINAPI_PARTITION_DESKTOP (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
  127. #endif
  128. #ifndef WINAPI_PARTITION_APP
  129. #define WINAPI_PARTITION_APP \
  130. (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || \
  131. WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || \
  132. WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  133. #endif
  134. #ifndef WINAPI_PARTITION_PC_APP
  135. #define WINAPI_PARTITION_PC_APP \
  136. (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || \
  137. WINAPI_FAMILY == WINAPI_FAMILY_PC_APP)
  138. #endif
  139. #ifndef WINAPI_PARTITION_PHONE_APP
  140. #define WINAPI_PARTITION_PHONE_APP (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  141. #endif
  142. /*
  143. * SYSTEM is the only partition defined here.
  144. * All other System based editions are defined as packages
  145. * on top of the System partition.
  146. * See winpackagefamily.h for packages level partitions
  147. */
  148. #ifndef WINAPI_PARTITION_SYSTEM
  149. #define WINAPI_PARTITION_SYSTEM \
  150. (WINAPI_FAMILY == WINAPI_FAMILY_SYSTEM || \
  151. WINAPI_FAMILY == WINAPI_FAMILY_SERVER)
  152. #endif
  153. /*
  154. * For compatibility with Windows Phone 8 header files, the following
  155. * synonym for WINAPI_PARTITION_PHONE_APP is temporarily #define'd.
  156. * Use of this symbol should be regarded as deprecated.
  157. */
  158. #define WINAPI_PARTITION_PHONE WINAPI_PARTITION_PHONE_APP
  159. /*
  160. * Header files use the WINAPI_FAMILY_PARTITION macro to assign one or
  161. * more declarations to some group of partitions. The macro chooses
  162. * whether the preprocessor will emit or omit a sequence of declarations
  163. * bracketed by an #if/#endif pair. All header file references to the
  164. * WINAPI_PARTITION_* values should be in the form of occurrences of
  165. * WINAPI_FAMILY_PARTITION(...).
  166. *
  167. * For example, the following usage of WINAPI_FAMILY_PARTITION identifies
  168. * a sequence of declarations that are part of both the Windows Desktop
  169. * Partition and the Windows-Phone-Specific Store Partition:
  170. *
  171. * #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP)
  172. * ...
  173. * #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP)
  174. *
  175. * The comment on the closing #endif allow tools as well as people to find the
  176. * matching #ifdef properly.
  177. *
  178. * Usages of WINAPI_FAMILY_PARTITION may be combined, when the partitition definitions are
  179. * related. In particular one might use declarations like
  180. *
  181. * #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  182. *
  183. * or
  184. *
  185. * #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
  186. *
  187. * Direct references to WINAPI_PARTITION_ values (eg #if !WINAPI_FAMILY_PARTITION_...)
  188. * should not be used.
  189. */
  190. #define WINAPI_FAMILY_PARTITION(Partitions) (Partitions)
  191. /*
  192. * Macro used to #define or typedef a symbol used for selective deprecation
  193. * of individual methods of a COM interfaces that are otherwise available
  194. * for a given set of partitions.
  195. */
  196. #define _WINAPI_DEPRECATED_DECLARATION __declspec(deprecated("This API cannot be used in the context of the caller's application type."))
  197. /*
  198. * For compatibility with Windows 8 header files, the following
  199. * symbol is temporarily conditionally #define'd. Additional symbols
  200. * like this should be not defined in winapifamily.h, but rather should be
  201. * introduced locally to the header files of the component that needs them.
  202. */
  203. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  204. # define APP_DEPRECATED_HRESULT HRESULT _WINAPI_DEPRECATED_DECLARATION
  205. #endif // WINAPIFAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  206. #if defined(_MSC_VER) && !defined(MOFCOMP_PASS)
  207. #if _MSC_VER >= 1200
  208. #pragma warning(pop)
  209. #endif
  210. #endif
  211. #endif /* !_INC_WINAPIFAMILY */