Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不知道是否已经有人问过同样的问题,但我无法使用 [c] [macro] "##" 在这里的高级搜索中找到它。
我想定义多个宏如下:
#define CHANNEL_0 0 #define CHANNEL_1 1 ... #define CHANNEL_31 31
我可以用这个符号## 以一种简单的方式来做吗?如何?或者也许有一些方法?
谢谢!
我不认为“##”是这里最好的解决方案。为什么不只使用enum?如果只需要 0 到 31 之间的数字,我认为没有理由不能使用它。
enum eChannel { Channel0, /* evaluates to 0 */ Channel1, /* evaluates to 1 */ ... Channel31 /* evaluates to 31 */ };
用法和#defines一样
if(channel == Channel1) do_smth();