[PATCH 06/13] Installed header hygiene (BZ#20366): Macros used in #if without checking whether they are defined.

Carlos O'Donell carlos@redhat.com
Wed Sep 21 19:09:00 GMT 2016


On 09/21/2016 02:46 PM, Paul Eggert wrote:
> On 09/21/2016 11:40 AM, Carlos O'Donell wrote:
>> Isn't that just a normal coordination issue with gnulib?
> 
> I think so. Gnulib could readily change to follow whatever _LIBC
> practice is thought to be convenient for libc itself.
 
Thanks for confirming.

Best practice for macro APIs, where possible, is to always define the
macro e.g. set it to 0 or 1, and then enable the use of -Wundef to catch
any mistakes.

This isn't always possible with defines coming from other projects or
the compiler itself (where behaviour is standardized), but in our own
GNU projects I think we could adopt the less error prone usages.

I'm not suggesting Zack tackle this now.

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list