Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

Cross-Platform Conditional Compilation Symbols

Describes the conditional compilation variables available for maintaining common source code in XNA Game Studio cross-platform projects.

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 platformXbox 360 platformWindows Phone platform
WINDOWSXBOX or XBOX360WINDOWS_PHONE

Usage

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
    

Definition

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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.