1 @c attribute module documentation
3 @c Copyright 2020 Free Software Foundation, Inc.
5 @c Permission is granted to copy, distribute and/or modify this document
6 @c under the terms of the GNU Free Documentation License, Version 1.3 or
7 @c any later version published by the Free Software Foundation; with no
8 @c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
9 @c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.
17 This module provides a header file @file{attribute.h} that defines
18 macros related to C and C++ attributes and the GCC
19 @code{__attribute__} keyword.
21 Here is an example of its use:
24 #include <attribute.h>
26 extern char *crypt (char const *, char const *)
27 ATTRIBUTE_NOTHROW ATTRIBUTE_LEAF ATTRIBUTE_NONNULL ((1, 2));
31 @code{ATTRIBUTE_NOTHROW} expands to @code{__attribute__
32 ((__nothrow__))} if the compiler is a recent-enough GCC or GCC-like
33 compiler, and to nothing otherwise. Similarly for
34 @code{ATTRIBUTE_LEAF}. @code{ATTRIBUTE_NONNULL ((1, 2))} expands to
35 @code{__attribute__ ((__nonnull__ (1, 2)))} if the compiler is
36 recent-enough GCC, and to nothing otherwise.
38 Most of these attribute names begin with @code{ATTRIBUTE_}.
39 A few do not, because they are part of C2X and their
40 names are not likely to clash with other macro names.
41 These macros are @code{DEPRECATED}, @code{FALLTHROUGH},
42 @code{MAYBE_UNUSED}, and @code{NODISCARD}, which can
43 be defined to @code{[[deprecated]]} etc.@: on C2X platforms.