Using and returning output in C macro

后端 未结 5 1705
说谎
说谎 2021-02-02 12:33

I\'m trying to instrument some code to catch and print error messages. Currently I\'m using a macro somethng like this:

#define my_function(x) \\
  switch(functi         


        
5条回答
  •  孤城傲影
    2021-02-02 12:45

    GCC has a feature called statement expressions

    So if define macro like

    #define FOO(A) ({int retval; retval = do_something(A); retval;})
    

    then you will be able to use it like

    foo = FOO(bar);
    

提交回复
热议问题