Using and returning output in C macro
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);
This is relatively complicated code, there is not much reason to have it in a macro. Make it inline
(C99) or static
(C89) or both if you really want to place it in a header file. With any reasonable compiler this then should result in the same efficiency as a macro.