+
+ 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
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_snprintf_pos_params" = "yes"; then
+ AC_DEFINE(HAVE_UNIX98_PRINTF)
+ fi