__has_c_attribute is a C23 preprocessor feature-test operator. Use it in a preprocessor conditional to test whether an attribute is supported before applying that attribute. section 10.2.3
Guarding a format attribute
The conditional applies the GNU format attribute only when the implementation reports support. The attribute tells the compiler that snprintf uses a printf-style format at argument 3 and begins its variable arguments at argument 4, enabling format warnings. section 10.2.3
#if __has_c_attribute(__gnu__::__format__) [[__gnu__::__format__(__printf__, 3, 4)]] #endif int snprintf(char *buf, size_t size, const char *frmt, ...);
Inspect a conditional declaration using __has_c_attribute and the double-underscore form of the prefixed format attribute. section 10.2.3
#ifndef __has_c_attribute # define __has_c_attribute(X) 0 #endif
Inspect a fallback definition that makes an unavailable __has_c_attribute operator evaluate to zero. section 10.2.3
