[Python-Dev] if/else and macros
Greg Stein
gstein@lyra.org
Mon, 17 Jul 2000 02:39:50 -0700
On Mon, Jul 17, 2000 at 11:17:41AM +0200, Thomas Wouters wrote:
> On Mon, Jul 17, 2000 at 02:05:32AM -0700, Greg Stein wrote:
> > On Mon, Jul 17, 2000 at 09:55:02AM +0200, M.-A. Lemburg wrote:
>
> > > and it produces warnings which relate to the fact that the "else"
> > > part is ambiguous:
> > >
> > > if (condition) UTF8_ERROR();
> > > else {...}
> > >
> > > expands to:
> > >
> > > if (condition)
> > > if (1) {...}
> > > else ;
> > > else {...}
> >
> > That is not ambiguous.
>
> Nope. The example was flawed. *this* is ambiguous:
>
> if (condition) UTF8_ERROR();
>
> And that's exactly what gcc is whining about:
>
> if (s + n > e)
> UTF8_ERROR("unexpected end of data");
Oh come on. This is getting silly.
Neither of those examples are ambiguous. C has a very strict definition of
what happens. In your examples, it expands to:
if (condition)
if (1) {
...
} else
;
GCC spits out a warning to tell the person "oh hey... I'm associating that
else with the second 'if' command... but I'm going to spit out a warning
just in case that isn't want you really meant."
There is no ambiguity. Zero. I repeat: none.
GCC is simply *assuming* that you may have messed up, so it spits out a
warning.
But ambiguity? Not at all.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/