From: Vadim Zeitlin Date: Sat, 18 Jan 2003 02:33:13 +0000 (+0000) Subject: attempts to fix vsnprintf() detection under HP-UX X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ec0d6da38d2cf84d69d5bb2d49effb13ed169c64?hp=677eb52d3f3775b25a9dbdf0526785487be675a1 attempts to fix vsnprintf() detection under HP-UX git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18808 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/configure.in b/configure.in index de58e1d076..33d93c5d22 100644 --- a/configure.in +++ b/configure.in @@ -3151,11 +3151,44 @@ AC_LANG_SAVE AC_LANG_CPLUSPLUS dnl check for vsnprintf() -- a safe version of vsprintf()) +dnl +dnl the trouble here is that on some systems (notable HP-UX) this function is +dnl present in libc but not in the system headers and so AC_CHECK_FUNCS (which, +dnl stupidly, provides a dummy function declaration inside its extension) +dnl succeeds, even with C++ compiler, but the compilation of wxWindows fails +dnl +dnl so we first check if the function is in the library AC_CHECK_FUNCS(vsnprintf) +if test "$ac_cv_func_vsnprintf" = "yes"; then + dnl yes it is -- now check if it is in the headers + AC_CACHE_CHECK([for vsnprintf declaration], wx_cv_func_vsnprintf_decl, + [ + AC_TRY_COMPILE( + [ + #include + #include + ], + [ + char *buf; + va_list ap; + vsnprintf(buf, 10u, "%s", ap); + ], + wx_cv_func_vsnprintf_decl=yes, + wx_cv_func_vsnprintf_decl=no + ) + ] + ) + + if test "$wx_cv_func_vsnprintf_decl" = "yes"; then + AC_DEFINE(HAVE_VSNPRINTF_DECL) + fi +fi + if test "$wxUSE_UNICODE" = yes; then dnl also look if we have wide char IO functions AC_CHECK_FUNCS(fputwc wprintf vswprintf) + 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... diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index 03a406d0ff..88ea300646 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -594,6 +594,15 @@ WXDLLEXPORT bool wxOKlibc(); // for internal use // printf() family saga // ---------------------------------------------------------------------------- +/* + For some systems vsnprintf() exists in the system libraries but not in the + headers, so we need to declare it ourselves to be able to use it. + */ +#ifndef HAVE_VSNPRINTF_DECL + extern "C" + int vsnprintf(char *str, size_t size, const char *format, va_list ap); +#endif // !HAVE_VSNPRINTF_DECL + /* First of all, we always want to define safe snprintf() function to be used instead of sprintf(). Some compilers already have it (or rather vsnprintf() diff --git a/setup.h.in b/setup.h.in index 6662300776..ab759d6ee5 100644 --- a/setup.h.in +++ b/setup.h.in @@ -964,6 +964,9 @@ /* Define if you have vsnprintf() */ #undef HAVE_VSNPRINTF +/* Define if you have vsnprintf() declaration in the header */ +#undef HAVE_VSNPRINTF_DECL + /* Define if you have usleep() */ #undef HAVE_USLEEP diff --git a/setup.h_vms b/setup.h_vms index 43530a6b23..60101dae62 100644 --- a/setup.h_vms +++ b/setup.h_vms @@ -993,6 +993,9 @@ /* Define if you have vsnprintf() */ #undef HAVE_VSNPRINTF +/* Define if you have vsnprintf() declaration in the header */ +#undef HAVE_VSNPRINTF_DECL + /* Define if you have usleep() */ #define HAVE_USLEEP 1