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>
36 # define __BEGIN_DECLS extern "C" {
38 # define __BEGIN_DECLS /* nothing */
43 # define __END_DECLS }
45 # define __END_DECLS /* nothing */
50 /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
52 # define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
55 # if defined __GNUC__ && defined __GNUC_MINOR__
56 # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
58 # define __GNUC_PREREQ(maj, min) 0
63 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
64 # if __cplusplus >= 201103L
65 # define __THROW noexcept (true)
67 # define __THROW throw ()
74 #endif /* _GETOPT_CDEFS_H */