[Python-Dev] Py_DECREF causes spurious gcc warning (original) (raw)
Zack Weinberg zack at codesourcery.com
Fri Dec 19 13:08:52 EST 2003
- Previous message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Next message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
martin at v.loewis.de (Martin v. Löwis) writes:
"Zack Weinberg" <zack at codesourcery.com> writes:
> This is what leads to the bletcherous > > do { > the real macro guts go here > } while(0) > > form of macro definition. PyDECREF could be rewritten in that form -- but > I've puked enough for one day .
Should, not just could. Yeah, it's bletcherous, but it's the only way to be sure. (Short of inline functions.) Not true. As Tim explains, there is no possible application of the macro which gets misinterpreted. We don't have a single if-statement, we have an if-else-statement in the macro. That never leads to the dangling else problem.
It does, however, lead to a different problem:
if (condition) Py_DECREF (foo); else // oops, syntax error here ...
In general I consider it appropriate to wrap all macros that don't return a value in do { ... } while (0), because that way you don't have to worry about which of them truly need it.
zw
- Previous message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Next message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]