Debian Codegraph @

lib/getopt-pfx-core.h

raw
1 /* getopt (basic, portable features) gnulib wrapper header.
2 Copyright (C) 1989-2026 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.
6
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.
11
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.
16
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/>. */
19
20 #ifndef _GETOPT_PFX_CORE_H
21 #define _GETOPT_PFX_CORE_H 1
22
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. */
26
27 /* Standalone applications should #define __GETOPT_PREFIX to an
28 identifier that prefixes the external functions and variables
29 defined in getopt-core.h and getopt-ext.h. Systematically
30 rename identifiers so that they do not collide with the system
31 functions and variables. Renaming avoids problems with some
32 compilers and linkers. */
33 #ifdef __GETOPT_PREFIX
34
35 /* Include platform-dependent header files that may declare getopt() and
36 friends. */
37 # if defined _AIX || defined __hpux || defined __sun || defined __QNX__
38 # include <stdio.h>
39 # endif
40 # if defined MUSL_LIBC || (defined __FreeBSD__ || defined __DragonFly__) || defined __NetBSD__ || defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined _AIX || defined __sun || defined __minix || defined __HAIKU__
41 # include <unistd.h>
42 # endif
43
44 # ifndef __GETOPT_ID
45 # define __GETOPT_CONCAT(x, y) x ## y
46 # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
47 # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
48 # endif
49 # undef getopt
50 # undef optarg
51 # undef opterr
52 # undef optind
53 # undef optopt
54 # define getopt __GETOPT_ID (getopt)
55 # define optarg __GETOPT_ID (optarg)
56 # define opterr __GETOPT_ID (opterr)
57 # define optind __GETOPT_ID (optind)
58 # define optopt __GETOPT_ID (optopt)
59
60 /* Work around a problem on macOS, which declares getopt with a
61 trailing __DARWIN_ALIAS(getopt) that would expand to something like
62 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
63 hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
64 # ifdef __APPLE__
65 # define _GETOPT
66 # endif
67
68 /* The system's getopt.h may have already included getopt-core.h to
69 declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
70 getopt-core.h declares them with prefixes. */
71 # undef _GETOPT_CORE_H
72 #endif
73
74 #include <getopt-core.h>
75
76 #endif /* _GETOPT_PFX_CORE_H */