+ dnl we know there is a vsnprintf declaration, but some old headers
+ dnl may have one taking a "char *" format instead of "const char *"
+ AC_CACHE_CHECK([if vsnprintf declaration is broken], wx_cv_func_broken_vsnprintf_decl,
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <stdio.h>
+ #include <stdarg.h>
+ #ifdef __MSL__
+ #if __MSL__ >= 0x6000
+ namespace std {}
+ using namespace std;
+ #endif
+ #endif
+ ],
+ [
+ char *buf;
+ va_list ap;
+ const char *fmt = "%s";
+ vsnprintf(buf, 10u, fmt, ap);
+ ],
+ wx_cv_func_broken_vsnprintf_decl=no,
+ wx_cv_func_broken_vsnprintf_decl=yes
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_broken_vsnprintf_decl" = "yes"; then
+ AC_DEFINE(HAVE_BROKEN_VSNPRINTF_DECL)
+ fi
+ fi
+fi
+
+dnl the same as above but for snprintf() now: it's not present in at least AIX
+dnl 4.2 headers
+if test "$ac_cv_func_snprintf" = "yes"; then
+ AC_CACHE_CHECK([for snprintf declaration], wx_cv_func_snprintf_decl,
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <stdio.h>
+ #include <stdarg.h>
+ #ifdef __MSL__
+ #if __MSL__ >= 0x6000
+ namespace std {}
+ using namespace std;
+ #endif
+ #endif
+ ],
+ [
+ char *buf;
+ snprintf(buf, 10u, "%s", "wx");
+ ],
+ wx_cv_func_snprintf_decl=yes,
+ wx_cv_func_snprintf_decl=no
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_snprintf_decl" = "yes"; then
+ AC_DEFINE(HAVE_SNPRINTF_DECL)
+
+ dnl we know there is an snprintf declaration, but some old headers
+ dnl may have one taking a "char *" format instead of "const char *"
+ AC_CACHE_CHECK([if snprintf declaration is broken], wx_cv_func_broken_snprintf_decl,
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <stdio.h>
+ #include <stdarg.h>
+ #ifdef __MSL__
+ #if __MSL__ >= 0x6000
+ namespace std {}
+ using namespace std;
+ #endif
+ #endif
+ ],
+ [
+ char *buf;
+ const char *fmt = "%s";
+ snprintf(buf, 10u, fmt, "wx");
+ ],
+ wx_cv_func_broken_snprintf_decl=no,
+ wx_cv_func_broken_snprintf_decl=yes
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_broken_snprintf_decl" = "yes"; then
+ AC_DEFINE(HAVE_BROKEN_SNPRINTF_DECL)
+ fi
+ fi
+
+ if test "$wxUSE_PRINTF_POS_PARAMS" = "yes"; then
+
+ dnl check if snprintf() has support for positional arguments
+ dnl NB: if snprintf() has positional support we can safely suppose that also
+ dnl other *printf() functions support them as they all belong to the same
+ dnl family and they all fallback to the same implementation
+ AC_CACHE_CHECK([if snprintf supports positional arguments], wx_cv_func_snprintf_pos_params,
+ [
+ AC_TRY_RUN(
+ [
+ #include <stdio.h>
+
+ int main (void)
+ {
+ char buffer[128];
+ snprintf (buffer, 128, "%2\$d %3\$d %1\$d", 1, 2, 3);
+ if (strcmp ("2 3 1", buffer) == 0)
+ exit (0);
+ exit (1);
+ }
+ ],
+ wx_cv_func_snprintf_pos_params=no,
+ wx_cv_func_snprintf_pos_params=yes,
+ dnl be pessimistic when cross-compiling
+ [
+ AC_MSG_WARN([Assuming Unix98 printf() is not available,
+define HAVE_UNIX98_PRINTF as 1 in setup.h if it is available.])
+ wx_cv_func_snprintf_pos_params=no
+ ]
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_snprintf_pos_params" = "yes"; then
+ AC_DEFINE(HAVE_UNIX98_PRINTF)
+ fi
+ fi
+fi
+
+if test "$wxUSE_UNICODE" = yes; then
+
+ dnl our wxVsnprintf() implementation needs to use the system swprintf() in Unicode
+ dnl builds so let's check if swprintf() is declared as C99 imposes:
+ dnl int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...);
+ dnl or rather as:
+ dnl int swprintf(wchar_t *s, const wchar_t *format, ...);
+ AC_CHECK_FUNCS(swprintf)
+
+ if test "$ac_cv_func_swprintf" = "yes"; then
+ AC_CACHE_CHECK([if swprintf declaration is broken], wx_cv_func_broken_swprintf_decl,
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <wchar.h>
+ ],
+ [
+ wchar_t *buf;
+ const wchar_t *fmt = L"test";
+ swprintf(buf, 10u, fmt);
+ ],
+ wx_cv_func_broken_swprintf_decl=no,
+ wx_cv_func_broken_swprintf_decl=yes
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_broken_swprintf_decl" = "yes"; then
+ AC_DEFINE(HAVE_BROKEN_SWPRINTF_DECL)
+ fi
+ fi
+
+ dnl also look if we have wide char IO functions, notice that [f]putws are
+ dnl declared in special widec.h under Solaris
+ wchar_headers="#include <stdio.h>
+#include <wchar.h>"
+ case "${host}" in
+ *-*-solaris2* )
+ AC_CHECK_HEADERS(widec.h)
+ if test "$ac_cv_header_widec_h" = "yes"; then
+ wchar_headers="$wchar_headers
+#include <widec.h>"
+ fi
+ esac
+
+ WX_CHECK_FUNCS(wputc wputchar putws fputws wprintf vswprintf,,,
+ [$wchar_headers])
+
+ dnl MinGW has a vswprintf with a different prototype, and
+ dnl a _vsnwprintf with the correct prototype, but AC_CHECK_FUNCS
+ dnl finds it even if it is not declared in some versions...
+ AC_MSG_CHECKING([for _vsnwprintf])
+ AC_TRY_COMPILE([#include <wchar.h>],
+ [&_vsnwprintf;],