[Python-Dev] Py_DECREF causes spurious gcc warning

Martin v. Löwis martin at v.loewis.de
Sat Dec 20 05:31:18 EST 2003

"Zack Weinberg" <zack at codesourcery.com> writes:

> It does, however, lead to a different problem:
>   if (condition)
>     Py_DECREF (foo);
>   else               // oops, syntax error here

How so? This expands to

  else action2;

This is perfectly well-formed C, and it groups as my
indentation suggests.

There is no real problem with this macro. It is just gcc complaining

> 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.

Hmm. Yes, this could be done - but it is unfortunate that this needs
to be done only to silence gcc.


More information about the Python-Dev mailing list