0
我有宏:如何獲取宏功能的名稱?
#define MYMACRO(pred, ...) \
pred /* here 'pred' is 'mypred(1, 2)', but I need to get only the name without args */
這是用這樣的:
MYMACRO(mypred(1, 2))
我需要得到宏觀功能的只有名字,不帶參數。
我能做到這一點是這樣的:
#define mypred(...) \
mypred
#define MYMACRO_EXPAND(pred) \
pred /* here 'pred' is 'mypred' without args */
#define MYMACRO(pred, ...) \
MYMACRO_EXPAND(pred)
但是這樣是不好的,因爲我要定義宏的所有可能的宏觀功能。 想法?
這聽起來像一個XY問題。實際上你試圖解決什麼? – 2014-10-16 19:47:18