getopt-pfx-ext.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* getopt (GNU extensions) gnulib wrapper header.
  2. Copyright (C) 1989-2017 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. gnulib is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as
  8. published by the Free Software Foundation; either version 3 of
  9. the License, or (at your option) any later version.
  10. gnulib is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. General Public License for more details.
  14. You should have received a copy of the GNU General Public
  15. License along with gnulib; if not, see
  16. <http://www.gnu.org/licenses/>. */
  17. #ifndef _GETOPT_PFX_EXT_H
  18. #define _GETOPT_PFX_EXT_H 1
  19. /* This header should not be used directly; include getopt.h instead.
  20. It does not have a protective #error, because the guard macro for
  21. getopt.h in gnulib is not fixed. */
  22. /* Standalone applications should #define __GETOPT_PREFIX to an
  23. identifier that prefixes the external functions and variables
  24. defined in getopt-core.h and getopt-ext.h. Systematically
  25. rename identifiers so that they do not collide with the system
  26. functions and variables. Renaming avoids problems with some
  27. compilers and linkers. */
  28. #ifdef __GETOPT_PREFIX
  29. # ifndef __GETOPT_ID
  30. # define __GETOPT_CONCAT(x, y) x ## y
  31. # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
  32. # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
  33. # endif
  34. # undef getopt_long
  35. # undef getopt_long_only
  36. # undef option
  37. # undef _getopt_internal
  38. # define getopt_long __GETOPT_ID (getopt_long)
  39. # define getopt_long_only __GETOPT_ID (getopt_long_only)
  40. # define option __GETOPT_ID (option)
  41. # define _getopt_internal __GETOPT_ID (getopt_internal)
  42. #endif
  43. /* Standalone applications get correct prototypes for getopt_long and
  44. getopt_long_only; they declare "char **argv". For backward
  45. compatibility with old applications, if __GETOPT_PREFIX is not
  46. defined, we supply GNU-libc-compatible, but incorrect, prototypes
  47. using "char *const *argv". (GNU libc is stuck with the incorrect
  48. prototypes, as they are baked into older versions of LSB.) */
  49. #ifndef __getopt_argv_const
  50. # if defined __GETOPT_PREFIX
  51. # define __getopt_argv_const /* empty */
  52. # else
  53. # define __getopt_argv_const const
  54. # endif
  55. #endif
  56. #include <getopt-ext.h>
  57. #endif /* _GETOPT_PFX_EXT_H */