Re:Tips on writing C macros
by paulbaumgart on Tuesday August 04, 2009 @08:44PM
(#742543)
Same with what I suggested:
-----
Edit: Just for context: this was responding to a post pointing out that the do-while construct allows you to use a semi-colon after the macro invocation.
[ Parent
| on HN ]
And another feature I like about ({ }) macros (anyone know the proper name here?) is you can return values. Clearly more useful in an example a bit more complex but...
#define ADD_ONE(a) ({ a + 1; })
x = ADD_ONE(2);
Re:Tips on writing C macros
by tedunangst on Tuesday August 04, 2009 @09:15PM
(#742599)
They are called statement expressions.