1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 /* getopt-on-non-glibc compatibility macros.
4 Copyright (C) 1989-2023 Free Software Foundation, Inc.
5 This file is part of gnulib.
6 Unlike most of the getopt implementation, it is NOT shared
7 with the GNU C Library.
9 This file is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
14 This file is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <https://www.gnu.org/licenses/>. */
22 #ifndef _GETOPT_CDEFS_H
23 #define _GETOPT_CDEFS_H 1
25 /* This header should not be used directly; include getopt.h or
26 unistd.h instead. It does not have a protective #error, because
27 the guard macro for getopt.h in gnulib is not fixed. */
29 /* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
30 a number of the internal macros supplied to GNU libc's headers by
31 sys/cdefs.h. Provide fallback definitions for all of them. */
32 #ifdef HAVE_SYS_CDEFS_H
33 # include <sys/cdefs.h>
38 # define __BEGIN_DECLS extern "C" {
40 # define __BEGIN_DECLS /* nothing */
45 # define __END_DECLS }
47 # define __END_DECLS /* nothing */
52 # if defined __GNUC__ && defined __GNUC_VERSION__
53 # define __GNUC_PREREQ(maj, min) \
54 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
56 # define __GNUC_PREREQ(maj, min) 0
61 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
62 # if __cplusplus >= 201103L
63 # define __THROW noexcept (true)
65 # define __THROW throw ()
72 #endif /* _GETOPT_CDEFS_H */