Ruby: include/ruby/internal/has/c_attribute.h Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

c_attribute.h
Go to the documentation of this file.
1#ifndef RBIMPL_HAS_C_ATTRIBUTE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_HAS_C_ATTRIBUTE_H
23
24#include "ruby/internal/has/extension.h"
25#include "ruby/internal/has/warning.h"
26
28#if defined(__cplusplus)
29# /* Makes no sense. */
30# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
31
32#elif RBIMPL_HAS_EXTENSION(c_attributes)
33# /* Hmm. It seems Clang 17 has this macro defined even when -std=c99 mode,
34# * _and_ fails to compile complaining that attributes are C2X feature. We
35# * need to work around this nonsense. */
36# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
37
38#elif RBIMPL_HAS_WARNING("-Wc2x-extensions")
39# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
40
41#elif defined(__has_c_attribute)
42# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
43
44#else
45# /* As of writing everything that lacks __has_c_attribute also completely
46# * lacks C2x attributes as well. Might change in future? */
47# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
48#endif
49
50#endif /* RBIMPL_HAS_C_ATTRIBUTE_H */
warning.h
Defines RBIMPL_HAS_WARNING.
extension.h
Defines RBIMPL_HAS_EXTENSION.