[Bug c/53182] GNU C: attributes without underscores should be discouraged / no longer be documented e.g. as examples
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Tue Feb 25 15:32:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53182
--- Comment #8 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Jonathan Wakely from comment #7)
> (In reply to Vincent Lefèvre from comment #6)
> > Also, note that identifiers that are not reserved should not be used,
> > because they could be defined as macros by the developer, who has not tested
> > his code with GCC (I'm saying GCC here, but this applies to any compiler).
>
> Should not be used by who?
by non-user code, but this applies in particular to what's inside
__attribute__.
Here's an example. In MPFR's mpfr.h file, we use:
#define __MPFR_SENTINEL_ATTR
#if defined (__GNUC__)
# if __GNUC__ >= 4
# undef __MPFR_SENTINEL_ATTR
# define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
# endif
#endif
But if in my personal C code, I have
#define sentinel 1
before the #include's or, in a similar way, compile my program with -Dsentinel,
then I get a compilation failure. Here the end user is not supposed to know
that the identifier "sentinel" (which is not reserved) is used internally.
More information about the Gcc-bugs
mailing list