Re: iterator macros and requiring gcc >= 3.0 and -std=c9x
[email protected] (Neal H. Walfield)
| Newsgroups | gmane.os.hurd.devel.readers |
|---|---|
| Message-ID | <[email protected]> |
> 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.