Blame m4/wint_t.m4

Packit 709fb3
# wint_t.m4 serial 7
Packit 709fb3
dnl Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
Packit 709fb3
dnl This file is free software; the Free Software Foundation
Packit 709fb3
dnl gives unlimited permission to copy and/or distribute it,
Packit 709fb3
dnl with or without modifications, as long as this notice is preserved.
Packit 709fb3
Packit 709fb3
dnl From Bruno Haible.
Packit 709fb3
dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
Packit 709fb3
dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
Packit 709fb3
dnl Prerequisite: AC_PROG_CC
Packit 709fb3
Packit 709fb3
AC_DEFUN([gt_TYPE_WINT_T],
Packit 709fb3
[
Packit 709fb3
  AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
Packit 709fb3
    [AC_COMPILE_IFELSE(
Packit 709fb3
       [AC_LANG_PROGRAM(
Packit 709fb3
          [[
Packit 709fb3
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit 709fb3
   <wchar.h>.
Packit 709fb3
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
Packit 709fb3
   before <wchar.h>.  */
Packit 709fb3
#include <stddef.h>
Packit 709fb3
#include <stdio.h>
Packit 709fb3
#include <time.h>
Packit 709fb3
#include <wchar.h>
Packit 709fb3
            wint_t foo = (wchar_t)'\0';]],
Packit 709fb3
          [[]])],
Packit 709fb3
       [gt_cv_c_wint_t=yes],
Packit 709fb3
       [gt_cv_c_wint_t=no])])
Packit 709fb3
  if test $gt_cv_c_wint_t = yes; then
Packit 709fb3
    AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
Packit 709fb3
Packit 709fb3
    dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
Packit 709fb3
    dnl override 'wint_t'.
Packit 709fb3
    AC_CACHE_CHECK([whether wint_t is too small],
Packit 709fb3
      [gl_cv_type_wint_t_too_small],
Packit 709fb3
      [AC_COMPILE_IFELSE(
Packit 709fb3
           [AC_LANG_PROGRAM([[
Packit 709fb3
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit 709fb3
   <wchar.h>.
Packit 709fb3
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit 709fb3
   included before <wchar.h>.  */
Packit 709fb3
#if !(defined __GLIBC__ && !defined __UCLIBC__)
Packit 709fb3
# include <stddef.h>
Packit 709fb3
# include <stdio.h>
Packit 709fb3
# include <time.h>
Packit 709fb3
#endif
Packit 709fb3
#include <wchar.h>
Packit 709fb3
              int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
Packit 709fb3
              ]])],
Packit 709fb3
           [gl_cv_type_wint_t_too_small=no],
Packit 709fb3
           [gl_cv_type_wint_t_too_small=yes])])
Packit 709fb3
    if test $gl_cv_type_wint_t_too_small = yes; then
Packit 709fb3
      GNULIB_OVERRIDES_WINT_T=1
Packit 709fb3
    else
Packit 709fb3
      GNULIB_OVERRIDES_WINT_T=0
Packit 709fb3
    fi
Packit 709fb3
  else
Packit 709fb3
    GNULIB_OVERRIDES_WINT_T=0
Packit 709fb3
  fi
Packit 709fb3
  AC_SUBST([GNULIB_OVERRIDES_WINT_T])
Packit 709fb3
])
Packit 709fb3
Packit 709fb3
dnl Prerequisites of the 'wint_t' override.
Packit 709fb3
AC_DEFUN([gl_TYPE_WINT_T_PREREQ],
Packit 709fb3
[
Packit 709fb3
  AC_CHECK_HEADERS_ONCE([crtdefs.h])
Packit 709fb3
  if test $ac_cv_header_crtdefs_h = yes; then
Packit 709fb3
    HAVE_CRTDEFS_H=1
Packit 709fb3
  else
Packit 709fb3
    HAVE_CRTDEFS_H=0
Packit 709fb3
  fi
Packit 709fb3
  AC_SUBST([HAVE_CRTDEFS_H])
Packit 709fb3
])