Friday, October 05, 2012

#define FOO() do { ... } while(0)

Encountered this construct in a C/C+ macro.

This insists in FOO(); having a semicolon,

whereas if did #define FOO() { ... }
the semicolon is not required.

Hack.

Good hack for C.

But shows that C/C++ are stupid languages.

No comments:

Post a Comment