[Python-Dev] Py_DECREF causes spurious gcc warning (original) (raw)
Zack Weinberg zack at codesourcery.com
Sat Dec 20 14:42:51 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 ]
"Tim Peters" <tim.one at comcast.net> writes:
[Zack Weinberg]
It does, however, lead to a different problem:
if (condition) PyDECREF (foo); else // oops, syntax error here [Martin v. Löwis] How so? This expands to if(condition) if(cond2)action1; else action2; else [Zack] No, it expands to if(condition) if(cond2) action1; else action2;; else -- note the extra semicolon, which provokes a syntax error. Zack, which version of Python are you using? The current definition of PyDECREF doesn't end with a semicolon:
I thought you might come back at me with that. Yes, you can avoid the syntax error by carefully leaving off the semicolon here. I don't consider this to be good style, though. It's easy to forget, and it's easy for someone to come along later and be confused and check in an 'obvious' patch that adds a semicolon - and it might not even break anything... then.
I'm really not speaking about the python source code in specific. I'm speaking about general style principles, and I really do think it is good style always to wrap complex macros in do { } while (0) whether or not they 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 ]