Cross-Platform Conditional Compilation Symbols
XNA Game Studio projects define symbols for each compatible platform for use with conditional compilation directives such as #if. You can use this to maintain source code that acts differently on Windows, Xbox 360, or Windows Phone when that source is shared between projects.
The conditonal compilation symbols for each compatible platform are identified in the following table.
|Windows platform||Xbox 360 platform||Windows Phone platform|
|WINDOWS||XBOX or XBOX360||WINDOWS_PHONE|
Where source code needs to support different actions when executing on different platforms, it should use the XNA Game Studio conditional compilation symbols with the #if, #else and #elif directives.
For example, a game that needs to execute on Windows, Xbox 360, and Windows Phone, but calls different services (such as for input devices) for each platform, might use the directives in a style similar to this:
#if WINDOWS // Execute code that is specific to Windows #elif XBOX // Execute code that is specific to Xbox 360 #elif WINDOWS_PHONE // Execute code that is specific to Windows Phone #else // Print a compile-time error message #error The platform is not specified or is unsupported by this game. #endif
The Conditional compilation symbols are defined in the Build tab of the Project Designer properties for each project. These symbols are properly established when the XNA Game Studio project is first created or converted for another platform through the conversion wizard.