c语言宏开关 使用


/*

 * 宏的写法,宏的作用域,当前位置开始到大括号结束,如果没有大括号,到文件结尾。

 */

#include <stdio.h>

//#define HELLO

int main(int argc, const char * argv[]) {

    // insert code here...

#ifdef HELLO

    printf("Hello, World!\n");

#else

    printf("fjdla\n");

#endif

    

#define HELLO

#ifdef TEST

    printf("test\n");

#else 

    printf("else test\n");

#endif

    

    return 0;

}

 

 

fjdla

else test

Program ended with exit code: 0

 

 

1.vs只支持#ifdef #else #endif.      xcode支持#ifdef $elif #else #endif


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM