A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-December/041284.html below:

[Python-Dev] Py_DECREF causes spurious gcc warning

[Python-Dev] Py_DECREF causes spurious gcc warningZack Weinberg zack at codesourcery.com
Sat Dec 20 14:42:51 EST 2003
"Tim Peters" <tim.one at comcast.net> writes:

> [Zack Weinberg]
>>>> It does, however, lead to a different problem:
>>>>
>>>>   if (condition)
>>>>     Py_DECREF (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
> Py_DECREF 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

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4