This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH 1/2] Add __clang_has_extension to sys/cdefs.h.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 28 Apr 2016 15:16:20 -0700 (PDT)
- Subject: Re: [PATCH 1/2] Add __clang_has_extension to sys/cdefs.h.
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1461444595 dot git dot zackw at panix dot com> <7d28608ab5396836526b235526e0b757236cfc85 dot 1461444595 dot git dot zackw at panix dot com>
I think this is a bad addition. I don't think we want miscellaneous header
files to have Clang-specific #if checks. What we really want is for header
files to do specific feature checks using some compiler-independent macros
defined by <sys/cdefs.h>. This is also superior to the existing cases of
headers using __GNUC_PREREQ as a proxy for specific feature tests.
As Florian and Paul mentioned, new macros should avoid name space issues.
Just use the prefix __glibc_ on any new macro.
I think a generalized thing like __glibc_has_feature (foobar) would be
fine. sys/cdefs.h can do a variety of macro magic things to map that to
what works in Clang and to __GNUC_PREREQ for GCC. This is probably also
the best way to enable distros that backport features to their compilers to
update the corresponding conditionals easily, i.e. they can just patch
sys/cdefs.h in their glibc package to change some of these macro
definitions rather than dealing with the __GNUC_PREREQ mess throughout all
You don't need to do the whole conversion for us, of course. But look at
existing __GNUC_PREREQ tests and make sure that the scheme you come up with
will extend readily to cover all those cases.