This section lists the preprocessor definitions specific to Xbox One.
| Preprocessor Define | Description |
|---|---|
| _XBOX_ONE | This is the official define for Xbox One.
#ifdef _XBOX_ONE
// Xbox One
#elif _XBOX_VER >= 200
// Xbox 360
...
|
| _DURANGO | Legacy define, use _XBOX_ONE. |
| _TITLE | Together with _DURANGO or _XBOX_ONE it indicates the Game OS. The absence of _TITLE indicates the System OS.
#if _XBOX_ONE && defined(_TITLE)
// Game OS
|
| _M_X64, _M_IX86 and _M_ARM | When writing code that is specific to the processor architecture rather than the platform, you should make use of these defines. For Xbox 360, the equivalent would be _M_PPCBE. _M_AMD64 is an alias for _M_X64 and was the original name. It is being phased out in favor of _M_X64. Do not use the Windows legacy defines _X86_, _AMD64_, etc. |
| WINAPI_FAMILY | The Microsoft platform headers make extensive use of the Windows family and partition macros defined in winapifamily.h. It is important to remember that the partitions can (and in fact do between Windows 8.0 SDK and Windows 8.1 SDK) change. There are also new PARTITION and FAMILY values added over time. Client code should never make direct use of the PARTITION values, WINAPI_FAMILY_PARTITION macro, or the WINAPI_FAMILY_ONE_PARTITION macro. It is reasonable for client code to look for specific values of WINAPI_FAMILY. Note that the Windows 8.1 SDK version of winapifamily.h has an expanded comment block that covers this usage. |
| MONOLITHIC | For XDK apps check for this define to determine if using the Stock Direct3D runtime or the Monolithic Direct3D runtime.
#if MONOLITHIC
// Monolithic Direct3D
#else
// Stock Direct3D
...
|
It is best practice to use the following for Xbox One platform code:
#if _XBOX_ONE
And for Game OS specific code inside such a block:
#ifdef _TITLE
When building with the XDK, the VS IDE MS Build rules automatically define: _XBOX_ONE, _DURANGO, _TITLE, and WINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE. Developers who do not use the VS IDE to build against the XDK will have to supply these values on the compiler command-line.
/D_XBOX_ONE /D_DURANGO /D_TITLE /DWINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE
When building with the ADK, the VS IDE MS Build rules automatically define: __XBOX_ONE, DURANGO, and WINAPI_FAMILY=WINAPI_FAMILY_TV_APP. Developers who do not use the VS IDE to build against the ADK will have to supply these values on the compiler command-line.
/D_XBOX_ONE /D_DURANGO /DWINAPI_FAMILY=WINAPI_FAMILY_TV_APP
When writing Microsoft cross-platform code, the following construction is also generally applicable:
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
// This code is for Win32 desktop apps
#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
// This code is for Windows phone 8.x
#elif WINAPI_FAMILY == WINAPI_FAMILY_APP
// This code is for Microsoft Store apps for 8.x
#elif WINAPI_FAMILY == WINAPI_FAMILY_TV_TITLE
// This code is for Xbox One Game OS/XDK
#elif WINAPI_FAMILY == WINAPI_FAMILY_TV_APP
// This code is for Xbox One System OS/ADK
#else
#error Unknown WINAPI_FAMILY value
#endif