gettext: Sync with gettext 0.23.
[gnulib.git] / lib / getopt-cdefs.in.h
blob9d704a9f6e5567f4ac35920bfaa0b250984796e6
1 /* getopt-on-non-glibc compatibility macros.
2 Copyright (C) 1989-2024 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
12 This file 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 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 #ifndef _GETOPT_CDEFS_H
21 #define _GETOPT_CDEFS_H 1
23 /* This header should not be used directly; include getopt.h or
24 unistd.h instead. It does not have a protective #error, because
25 the guard macro for getopt.h in gnulib is not fixed. */
27 /* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
28 a number of the internal macros supplied to GNU libc's headers by
29 sys/cdefs.h. Provide fallback definitions for all of them. */
30 #if @HAVE_SYS_CDEFS_H@
31 # include <sys/cdefs.h>
32 #endif
34 #ifndef __BEGIN_DECLS
35 # ifdef __cplusplus
36 # define __BEGIN_DECLS extern "C" {
37 # else
38 # define __BEGIN_DECLS /* nothing */
39 # endif
40 #endif
41 #ifndef __END_DECLS
42 # ifdef __cplusplus
43 # define __END_DECLS }
44 # else
45 # define __END_DECLS /* nothing */
46 # endif
47 #endif
49 #if defined __clang__
50 /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
51 # undef __GNUC_PREREQ
52 # define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
53 #endif
54 #ifndef __GNUC_PREREQ
55 # if defined __GNUC__ && defined __GNUC_MINOR__
56 # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
57 # else
58 # define __GNUC_PREREQ(maj, min) 0
59 # endif
60 #endif
62 #ifndef __THROW
63 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
64 # if __cplusplus >= 201103L
65 # define __THROW noexcept (true)
66 # else
67 # define __THROW throw ()
68 # endif
69 # else
70 # define __THROW
71 # endif
72 #endif
74 #endif /* _GETOPT_CDEFS_H */