wchar.in.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
  2. Copyright (C) 2007 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. /* Written by Eric Blake. */
  15. /*
  16. * ISO C 99 <wchar.h> for platforms that have issues.
  17. * <http://www.opengroup.org/susv3xbd/wchar.h.html>
  18. *
  19. * For now, this just ensures proper prerequisite inclusion order and
  20. * the declaration of wcwidth().
  21. */
  22. #ifndef _GL_WCHAR_H
  23. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  24. <wchar.h>.
  25. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  26. included before <wchar.h>. */
  27. #include <stddef.h>
  28. #include <stdio.h>
  29. #include <time.h>
  30. /* Include the original <wchar.h> if it exists.
  31. Some builds of uClibc lack it. */
  32. /* The include_next requires a split double-inclusion guard. */
  33. #if @HAVE_WCHAR_H@
  34. # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
  35. #endif
  36. #ifndef _GL_WCHAR_H
  37. #define _GL_WCHAR_H
  38. /* The definition of GL_LINK_WARNING is copied here. */
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /* Return the number of screen columns needed for WC. */
  43. #if @GNULIB_WCWIDTH@
  44. # if @REPLACE_WCWIDTH@
  45. # undef wcwidth
  46. # define wcwidth rpl_wcwidth
  47. extern int wcwidth (wchar_t);
  48. # else
  49. # if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
  50. /* wcwidth exists but is not declared. */
  51. extern int wcwidth (int /* actually wchar_t */);
  52. # endif
  53. # endif
  54. #elif defined GNULIB_POSIXCHECK
  55. # undef wcwidth
  56. # define wcwidth(w) \
  57. (GL_LINK_WARNING ("wcwidth is unportable - " \
  58. "use gnulib module wcwidth for portability"), \
  59. wcwidth (w))
  60. #endif
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif /* _GL_WCHAR_H */
  65. #endif /* _GL_WCHAR_H */