I want to use a macro like this
#define Return(x) {call_my_function(); return (x);}
is there any way to use or declare a macro without parentheses, so I can use it like a real return call and not a function? For example:
BOOL my_func() {
code....
Return FALSE;
}
Function-like macros can take arguments, just like true functions. To define a macro that uses arguments, you insert parameters between the pair of parentheses in the macro definition that make the macro function-like. The parameters must be valid C identifiers, separated by commas and optionally whitespace.
The macro and its parameters should be enclosed in parentheses. When macro parameters or expression are not parenthesized, the intended logic may get disrupted after expanding the macro.
You could do something horrific as
#define Return for (call_my_function(); ;) return
Edit: Changed to Daniel's version for the nice smiley that makes. And Jim's idea of "overloading" return
directly is valid and even more horrific ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With