ano*_*non 24 c macros if-statement
有没有办法检查宏中的数字相等性?
我想做点什么
#define choice 3
#if choice == 3
....
#endif
#if choice == 4
...
#endif
Run Code Online (Sandbox Code Playgroud)
C宏是否支持这样的事情?
Dav*_*ble 29
编写代码的另一种方法是使用链式#elif指令:
#if choice == 3
...
#elif choice == 4
...
#else
#error Unsupported choice setting
#endif
Run Code Online (Sandbox Code Playgroud)
请注意,如果choice不是#defined,编译器(预处理器)会将其视为具有该值0.
| 归档时间: |
|
| 查看次数: |
52344 次 |
| 最近记录: |