Blame m4/wint_t.m4

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