宏等效(C/C++)?

RRR*_*RRR 0 c macros c-preprocessor

鉴于这个宏:

#define SOME_MACRO(ret, f, args) \
    typedef ret (*some_func_##f) args; \
    static some_func_##f my_func_##f = NULL;
Run Code Online (Sandbox Code Playgroud)

请让我知道相应的:

SOME_MACRO(void,  myFunctionName, (int a));
Run Code Online (Sandbox Code Playgroud)

谢谢.

per*_*eal 6

您可以使用-Egcc 的标志来查看宏的扩展方式:

typedef void (*some_func_myFunctionName) (int a); static some_func_myFunctionName my_func_myFunctionName = ((void *)0);;
Run Code Online (Sandbox Code Playgroud)

  • 您可以在MSVC中使用等效的`/ EP`开关. (2认同)