C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Ignorability of attributes: draft wording, and concern about __has_c_attribute

From: Robert Seacord <rcseacord_at_[hidden]>
Date: Tue, 7 Feb 2023 11:07:29 -0800
response inline below

On Tue, Feb 7, 2023 at 10:50 AM Timur Doumler <cpp_at_[hidden]> wrote:

> @SG22: Can you confirm this? What is the intent of __has_c_attribute in C:
> what Poll 1 says or what Poll 2 says?

 The intent in C is the same as Poll 1:

 __has_c_attribute should return a positive value for a standard attribute
only if it implements the semantics suggested in the specification of
the attribute.

The C Standard contains the following example in Subclause 6.10.1
Conditional inclusion, paragraph 17:

/* Fallback for compilers not yet implementing this feature. */
#ifndef __has_c_attribute
#define __has_c_attribute(x) 0
#endif /* __has_c_attribute */
#if __has_c_attribute(fallthrough)
/* Standard attribute is available, use it. */
#define FALLTHROUGH [[fallthrough]]
#elif __has_c_attribute(vendor::fallthrough)
/* Vendor attribute is available, use it. */
#define FALLTHROUGH [[vendor::fallthrough]]
/* Fallback implementation. */

How should we resolve this contradiction? Should we re-discuss that aspect
> of the paper in EWG, with someone from SG22 present?

Aaron Ballman would be the ideal person to represent the SG22 and WG14
positions, but if he is not available I would be willing to act as a poor


Received on 2023-02-07 19:07:42