C/C++ #define Macro inside macro?

前端 未结 4 1182
無奈伤痛
無奈伤痛 2021-01-18 13:04

I would like something like:

#define C_OR_CPP(C__, CPP__) #ifdef __cplusplus\\
CPP__\\
#else\\
C__\\
#endif

Is it possible? Maybe some dirt

4条回答
  •  春和景丽
    2021-01-18 13:31

    What's the problem with

    #ifdef __cplusplus
    #define C_OR_CPP(C, CPP) CPP
    #else
    #define C_OR_CPP(C, CPP) C
    #endif
    

    (Leaving names with double underscore to the implementation per phresnel remark)

提交回复
热议问题