Preprocessor variables

AdvancedProgrammer

If you're developing for multiple platforms, you often need to write custom code for each platform. In most cases, the best way to do this is to use Platform.Type and GraphicsDevice.Platform. Alternatively, you can use preprocessor variables.

Warning

We recommend you avoid using preprocessor variables where possible, and instead use Platform.Type and GraphicsDevice.Platform. This is because you might miss errors in your code, as only code for your target platform is checked at compile time.

Platforms

VariableValue
SILICONSTUDIO_PLATFORM_WINDOWSWindows (standard and RT)
SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOPWindows (non-RT)
SILICONSTUDIO_PLATFORM_WINDOWS_RTWindows RT
SILICONSTUDIO_PLATFORM_WINDOWS_PHONEWindows Phone
SILICONSTUDIO_PLATFORM_MONO_MOBILEXamarin.iOS or Xamarin.Android
SILICONSTUDIO_PLATFORM_ANDROIDXamarin.Android
SILICONSTUDIO_PLATFORM_IOSXamarin.iOS

Graphics APIs

VariableValue
Xenko_GRAPHICS_API_DIRECT3DDirect3D 11
Xenko_GRAPHICS_API_OPENGLOpenGL (Core and ES)
Xenko_GRAPHICS_API_OPENGLCOREOpenGL Core (Desktop)
Xenko_GRAPHICS_API_OPENGLESOpenGL ES
Xenko_GRAPHICS_API_VULKANVulkan

Example

  1. #if SILICONSTUDIO_PLATFORM_WINDOWS
  2. // Windows-specific code goes here...
  3. #elif SILICONSTUDIO_PLATFORM_MONO_MOBILE
  4. // iOS and Android-specific code goes here...
  5. #else
  6. // Other platform code goes here...
  7. #endif

See also