Overload C macros

前端 未结 2 1861
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 01:41

Is there a better way to \"overload\" a macro like this? I need a macro that accepts various numbers of parameters.

#define DEBUG_TRACE_1(p1) std::string p[]         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 02:31

    It is possible to use the standard C /C++ variadic args in macros, at least in gcc (EDIT: apparently they are standardized, and MS c compiler also has them).

    See this page for some information on how this works.

    There is also another question on this site which may be helpful for you.

提交回复
热议问题