wchar.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* wchar_t type related definitions.
  17. Copyright (C) 2000-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _BITS_WCHAR_H
  31. #define _BITS_WCHAR_H 1
  32. /* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__
  33. are not defined, give the right value and type as long as both int
  34. and wchar_t are 32-bit types. Adding L'\0' to a constant value
  35. ensures that the type is correct; it is necessary to use (L'\0' +
  36. 0) rather than just L'\0' so that the type in C++ is the promoted
  37. version of wchar_t rather than the distinct wchar_t type itself.
  38. Because wchar_t in preprocessor #if expressions is treated as
  39. intmax_t or uintmax_t, the expression (L'\0' - 1) would have the
  40. wrong value for WCHAR_MAX in such expressions and so cannot be used
  41. to define __WCHAR_MAX in the unsigned case. */
  42. #ifdef __WCHAR_MAX__
  43. # define __WCHAR_MAX __WCHAR_MAX__
  44. #elif L'\0' - 1 > 0
  45. # define __WCHAR_MAX (0xffffffffu + L'\0')
  46. #else
  47. # define __WCHAR_MAX (0x7fffffff + L'\0')
  48. #endif
  49. #ifdef __WCHAR_MIN__
  50. # define __WCHAR_MIN __WCHAR_MIN__
  51. #elif L'\0' - 1 > 0
  52. # define __WCHAR_MIN (L'\0' + 0)
  53. #else
  54. # define __WCHAR_MIN (-__WCHAR_MAX - 1)
  55. #endif
  56. #endif /* bits/wchar.h */