dnl CF_MBSTATE_T version: 5 updated: 2020/03/19 20:23:48
dnl ------------
dnl Check if mbstate_t is declared, and if so, which header file.
dnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
dnl as well as include stdio.h to work around a misuse of varargs in wchar.h
AC_DEFUN([CF_MBSTATE_T],
[
AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
AC_TRY_COMPILE([
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_LIBUTF8_H
#include <libutf8.h>
#endif],
	[mbstate_t state; (void)state],
	[cf_cv_mbstate_t=no],
	[AC_TRY_COMPILE([
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#ifdef HAVE_LIBUTF8_H
#include <libutf8.h>
#endif],
	[mbstate_t value; (void)value],
	[cf_cv_mbstate_t=yes],
	[cf_cv_mbstate_t=unknown])])])

if test "$cf_cv_mbstate_t" = yes ; then
	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
fi

if test "$cf_cv_mbstate_t" != unknown ; then
	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if mbstate_t is declared])
fi
])dnl
