[Python-Dev] if/else and macros
Thomas Wouters
thomas@xs4all.net
Tue, 25 Jul 2000 00:04:33 +0200
On Mon, Jul 24, 2000 at 09:38:15PM +0100, Barry Scott wrote:
> > > > ! #define UTF8_ERROR(details) \
> > > > ! if (1) { \
> > > > ! if (utf8_decoding_error(&s, &p, errors, (details))) \
> > > > ! goto onError; \
> > > > ! continue; \
> > > > ! } else
>
> Try defining the macro this way:
> #define UTF8_ERROR(details) \
> do { \
> if (utf8_decoding_error(&s, &p, errors, (details))) \
> goto onError; \
> continue; \
> } while(0)
That isn't going to work, and is the entire reason for the 'if' construction
rather than the 'do {} while' one: the 'continue' applies to the innermost
loop, the 'do {} while(0)', producing some decidedly unpredicted behaviour.
Anyhow, I believe it's fixed more adequately now, or someone is going to ;P
--
Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!