How to make a variadic macro (variable number of arguments)

前端 未结 5 1569
遥遥无期
遥遥无期 2020-11-22 11:48

I want to write a macro in C that accepts any number of parameters, not a specific number

example:

#define macro( X )  something_complicated( whateve         


        
5条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 12:43

    explained for g++ here, though it is part of C99 so should work for everyone

    http://www.delorie.com/gnu/docs/gcc/gcc_44.html

    quick example:

    #define debug(format, args...) fprintf (stderr, format, args)
    

提交回复
热议问题