Re: [tz] [PROPOSED 2/5] Pacify gcc -std=c89 -pedantic with new attributes
On 2022-11-28 12:47, Paul Eggert via tz wrote:
On 2022-11-28 05:40, Philip Newton wrote:
"have has" is a bit ugly....
Yes, I originally used the name "HAVE___HAS_C_ATTRIBUTE", since it tests whether __has_c_attribute exists and that's the naming convention, but I changed it to HAVE_HAS_C_ATTRIBUTE as I worried that the three adjacent underscores would be confusing. If people prefer HAVE___HAS_C_ATTRIBUTE we can easily change to that. The longer name would be more consistent.
"4.2.8 __has_c_attribute The special operator __has_c_attribute (operand) may be used in ‘#if’ and ‘#elif’ expressions in C code to test whether the attribute referenced by its operand is recognized by GCC in attributes using the ‘[[]]’ syntax." How about HAVE_C23_ATTRIBUTE_CHECK, HAVE_C2X_ATTRIBUTE_CHECK, or something similarly more meaningful and less confusing? -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry
On 11/29/22 12:21, Brian Inglis via tz wrote:
How about HAVE_C23_ATTRIBUTE_CHECK, HAVE_C2X_ATTRIBUTE_CHECK, or something similarly more meaningful and less confusing?
If one knows GCC and/or Clang well, the name HAVE_C23_ATTRIBUTE_CHECK could be confusing since the current releases of these compilers support __has_c_attribute even though they don't support C23 yet. Currently, private.h uses the naming convention of Autoconf, e.g., "HAVE_SYMLINK" is true if symlink(...) works. Although readers unfamiliar with POSIX might more easily understand a name like "HAVE_SYMBOLIC_LINKS", the name "HAVE_SYMLINK" is better for someone who knows the POSIX API since it looks more like a POSIX symlink(...) call. Similarly, HAVE___HAS_C_ATTRIBUTE is probably better for people who know about __has_c_attribute, including the fact that it's available on some popular non-C23 compilers. In looking through the HAVE_* identifiers I see one other identifier with a similar consistency issue, namely HAVE_GENERIC. To try to address this I installed the attached. It may be a bit uglier but at least it's a bit more consistent.
participants (2)
-
Brian Inglis -
Paul Eggert