1# mbstate_t.m4 serial 9 (fileutils-4.1.3)
2dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
3dnl This file is free software, distributed under the terms of the GNU
4dnl General Public License.  As a special exception to the GNU General
5dnl Public License, this file may be distributed as part of a program
6dnl that contains a configuration script generated by Autoconf, under
7dnl the same distribution terms as the rest of that program.
8
9# From Paul Eggert.
10
11# BeOS 5 has <wchar.h> but does not define mbstate_t,
12# so you can't declare an object of that type.
13# Check for this incompatibility with Standard C.
14
15# Include stdlib.h first, because otherwise this test would fail on Linux
16# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
17# a syntax error in wchar.h due to the use of undefined __int32_t.
18
19AC_DEFUN([AC_MBSTATE_T],
20  [
21   AC_CHECK_HEADERS(stdlib.h)
22
23   AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
24    [AC_TRY_COMPILE([
25#if HAVE_STDLIB_H
26# include <stdlib.h>
27#endif
28#include <wchar.h>],
29      [mbstate_t x; return sizeof x;],
30      ac_cv_type_mbstate_t=yes,
31      ac_cv_type_mbstate_t=no)])
32   if test $ac_cv_type_mbstate_t = no; then
33     AC_DEFINE(mbstate_t, int,
34	       [Define to a type if <wchar.h> does not define.])
35   fi])
36