getopt_posix.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Declarations for getopt (POSIX compatibility shim).
  2. Copyright (C) 1989-2021 Free Software Foundation, Inc.
  3. Unlike the bulk of the getopt implementation, this file is NOT part
  4. of gnulib.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <https://www.gnu.org/licenses/>. */
  16. #ifndef _GETOPT_POSIX_H
  17. #define _GETOPT_POSIX_H 1
  18. #if !defined _UNISTD_H && !defined _STDIO_H
  19. #error "Never include getopt_posix.h directly; use unistd.h instead."
  20. #endif
  21. #include <bits/getopt_core.h>
  22. __BEGIN_DECLS
  23. #if defined __USE_POSIX2 && !defined __USE_POSIX_IMPLICITLY \
  24. && !defined __USE_GNU && !defined _GETOPT_H
  25. /* GNU getopt has more functionality than POSIX getopt. When we are
  26. explicitly conforming to POSIX and not GNU, and getopt.h (which is
  27. not part of POSIX) has not been included, the extra functionality
  28. is disabled. */
  29. # ifdef __REDIRECT
  30. extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
  31. const char *__shortopts),
  32. __posix_getopt);
  33. # else
  34. extern int __posix_getopt (int ___argc, char *const *___argv,
  35. const char *__shortopts)
  36. __THROW __nonnull ((2, 3));
  37. # define getopt __posix_getopt
  38. # endif
  39. #endif
  40. __END_DECLS
  41. #endif /* getopt_posix.h */