Merge pull request #2796 from jimklimov/fix-docs-markup
[networkupstools.git] / include / attribute.h
blobf6ce29b4f41c414114c31e8698f4a463aed7f204
1 /* attribute.h - portability hacks for __attribute__ usage in other header files
3 Copyright (C) 2001 Russell Kroll <rkroll@exploits.org>
4 2005 Arnaud Quette <arnaud.quette@free.fr>
5 2020 Jim Klimov <jimklimov@gmail.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef NUT_ATTRIBUTE_H_SEEN
23 #define NUT_ATTRIBUTE_H_SEEN 1
25 /* To complicate matters, compilers with native support
26 * for the keyword may expose or not expose it as a macro...
27 * but for those that perform such courtesy, or are known
28 * supporters, we can put up the flag. For others, someone
29 * with those compilers should check and file PRs to NUT.
31 #if (!defined HAVE___ATTRIBUTE__) || (HAVE___ATTRIBUTE__ == 0)
32 # if ( defined(__GNUC__) && ( __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) ) ) || ( defined(__STRICT_ANSI__) && __STRICT_ANSI__ )
33 # ifndef __attribute__
34 # define __attribute__(x)
35 # endif
36 # ifndef HAVE___ATTRIBUTE__
37 # define HAVE___ATTRIBUTE__ 0
38 # endif
39 # else
40 # if defined(__clang__) || defined(__GNUC__) || defined(__SUNPRO_C)
41 # ifndef HAVE___ATTRIBUTE__
42 # define HAVE___ATTRIBUTE__ 1
43 # endif
44 # else
45 # ifndef HAVE___ATTRIBUTE__
46 # define HAVE___ATTRIBUTE__ 0
47 # endif
48 # endif
49 # endif
50 #endif
52 #if (!defined HAVE___ATTRIBUTE__) || (HAVE___ATTRIBUTE__ == 0)
53 # ifdef HAVE___ATTRIBUTE__UNUSED_ARG
54 # undef HAVE___ATTRIBUTE__UNUSED_ARG
55 # endif
56 # ifdef HAVE___ATTRIBUTE__UNUSED_FUNC
57 # undef HAVE___ATTRIBUTE__UNUSED_FUNC
58 # endif
59 # ifdef HAVE___ATTRIBUTE__NORETURN
60 # undef HAVE___ATTRIBUTE__NORETURN
61 # endif
62 # ifdef HAVE___ATTRIBUTE__
63 # undef HAVE___ATTRIBUTE__
64 # endif
65 #endif
67 /* Other source files now can simply check for `ifdef HAVE___ATTRIBUTE__*`
68 * as usual, and not bother about 0/1 values of the macro as well.
71 #endif /* NUT_ATTRIBUTE_H_SEEN */