Conditional Compilation Symbols

A conditional compilation symbol is a defined symbol that developers can use to perform certain actions that are meant not for the compiler, but rather for the preprocessor (preprocessing is a step that is run before compilation).

Specifically, in this example, the ZUNE symbol is defined whenever you are working with a Zune project. This symbol is defined in your project properties, which you can view by right-clicking the project and selecting Properties. In the Build tab of the properties window, you'll see a Conditional Compilation Symbols text box that contains all symbols defined for that particular build configuration for the project, as illustrated in Figure 8-8.

Conditional compilation symbols can be defined in the project properties window

Figure 8-8. Conditional compilation symbols can be defined in the project properties window

Among other things, conditional compilation symbols allow developers to surround code snippets with conditional statements that will cause it to compile only based on the presence or absence of the specified symbol.

For example, in your current project, you will see that the AudioEngine object is not defined in a Zune project and therefore cannot be used in the Zune version. An instance of the AudioEngine object is present in the Game1 class. This object needs to exist in the Windows version of the game in order to support XACT audio; however, not only do you not want XACT audio support in the ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.