[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iterator macros and requiring gcc >= 3.0 and -std=c9x

From: Neal H. Walfield
Subject: Re: iterator macros and requiring gcc >= 3.0 and -std=c9x
Date: 05 Sep 2002 19:19:52 -0400
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2

> I would like some iterator macros for the driver plugin code in the console
> client.  I have written this so far:
> #define driver_iterate(drv)                                             \
>   for (mutex_lock (&driver_list_lock), drv = &driver_list[0];           \
>        drv <= &driver_list[driver_list_len - 1];                        \
>        drv++, (drv == &driver_list[driver_list_len - 1]                 \
>                ? mutex_unlock (&driver_list_lock) : 0)

Despite the fact that there will only ever by a single driver_list, I
think it is clearer to write

#define driver_iterate(driver_list, driver) \

As a small note, you need to protect DRV during expansion by
surrounding it with parentheses.

> eliminating the need for a user-defined variable.  It's no big deal, but if
> you prefer the second version, we need to use -std=c9x in our CFLAGS.  What
> do you think?

The gcc 3.x manual recommends c99 over c9x.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]