C # Preprocessor Directives #define/#undefine/#if/#elif/#else/#endif

Source: Internet
Author: User

Preprocessor commands are very powerful and are used extensively during programming, such as easy to use in version release, 1, #define (tells the compiler that there is a symbol for the given name) #undefine (delete symbol) 2, #if#elif#else#endif#define本身没有什么作用, typically used in conjunction with other preprocessor directives (#if)
    1. Use # define to tell the compiler that a given symbol exists
    2. Add a name symbol to VS
    3. Use in Unity

 ----Use # define to tell the compiler that a given symbol exists--------------------------------------#define ANDROID #define IOS #define WP using System; using System.Collections.Generic; using system.linq; using system.text; using System.Threading.Tasks; namespace cshapeb { class Test     {#if ANDROID #if QD1 #elif QD2 #elif QD3 #endif #elif IOS #if QD1 #elif QD2 #elif QD3 #endif #elif WP #elif ELSE #else#endif    }}-----add a name symbol to VS--------------------------------------1,debug--> Configuration Manager.
2,debug-->< new ...>.
3, fill in the name Android_debug, and complete the setup, then we can see in DEBUGit's android_debug.

4, configure Android_debug, write the given name symbol in the conditional compilation symbol number, and save.
5, using, we are in the debug mode of words ourAndroid is not enabled, but we switch tounder the Android_debug.The code under the Android symbol is enabled.


-----Use in Unity--------------------------------------buildsetting->playersettings->scripting Define Symbols
-----Unity Pre-defined macros--------------------------------------Platform definition

Unity_editor Editor calls.
Unity_standalone_osx Specifically for the definition of Mac OS (including Universal, PPC, and Intelarchitectures) platforms.
Unity_dashboard_widget Mac OS Dashboard widget (Mac OS Dashboard widget).
Unity_standalone_win Windows.
Unity_standalone_linux A standalone application for Linux.
Unity_standalone Standalone platform (mac,windows or Linux).
Unity_webplayer Web player (including Windows and Mac Web Player executables).
Unity_wii Wii console platform.
Unity_iphone iphone platform.
Unity_android Android platform.
Unity_ps3 PlayStation 3.
unity_xbox360 Xbox 360.
Unity_nacl Google Native Client (use this must additionally use Unity_webplayer).
Unity_flash Adobe Flash.

You can also judge the Unity version, the currently supported version

Unity_2_6 The platform is defined as the major version of Unity 2.6.
Unity_2_6_1 Platform-defined version 1 of the major version 2.6.
Unity_3_0 The platform is defined as the major version of Unity 3.0.
Unity_3_0_0 The platform defines a specific version of Unity 3.0 0.
Unity_3_1 The platform is defined as the major version of Unity 3.1.
Unity_3_2 The platform is defined as the major version of Unity 3.2.
Unity_3_3 The platform is defined as the major version of Unity 3.3.
Unity_3_4 The platform is defined as the major version of Unity 3.4.
Unity_3_5 The platform is defined as the major version of Unity 3.5.
Unity_4_0 The platform is defined as the major version of Unity 4.0.
Unity_4_0_1 Major Version 4.0.1 a unified platform definition.
Unity_4_1 The platform is defined as the major version of Unity 4.1.


From for notes (Wiz)

C # Preprocessor Directives #define/#undefine/#if/#elif/#else/#endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.