HPUX 11.00 snprintf fix
Zack Weinberg
zack@codesourcery.com
Mon Oct 20 19:33:00 GMT 2003
It's been reported to me that builds on HP-UX 11.00 bomb out due to
genmodes' use of snprintf. This function is in libc on this platform,
but declared with an incorrect prototype in stdio.h: the third
argument is char *, not const char *. Since that third argument
normally receives a string constant, -Wwrite-strings -Werror causes a
hard error and bootstrap fails. This would presumably also cause
trouble with C++.
I believe this is the appropriate fix. I do not have access to an
11.00 system to test it - I do have 11.11, but that system has the
correct snprintf prototype. I did run fixinc's make check, and
this test appears to do the right thing, but there are some weird
other failures due to missing or extra carriage returns.
zw
* fixinc/inclhack.def (hpux11_snprintf): New edit.
* fixinc/tests/base/stdio.h: Update.
===================================================================
Index: fixinc/inclhack.def
--- fixinc/inclhack.def 14 Oct 2003 11:46:47 -0000 1.183
+++ fixinc/inclhack.def 20 Oct 2003 19:31:44 -0000
@@ -1255,6 +1255,23 @@ fix = {
/*
+ * Fix hpux 11.00 broken snprintf declaration
+ * (third argument is char *, needs to be const char * to prevent
+ * spurious warnings with -Wwrite-strings or in C++).
+ */
+fix = {
+ hackname = hpux11_snprintf;
+ files = stdio.h;
+ select = '(extern int snprintf\(char \*, _[hpux]*_size_t,)'
+ ' (char \*, \.\.\.\);)';
+ c_fix = format;
+ c_fix_arg = '%1 const %2';
+
+ test_text = 'extern int snprintf(char *, _hpux_size_t, char *, ...);';
+};
+
+
+/*
* get rid of bogus inline definitions in HP-UX 8.0
*/
fix = {
===================================================================
Index: fixinc/tests/base/stdio.h
--- fixinc/tests/base/stdio.h 4 Apr 2003 21:46:49 -0000 1.10
+++ fixinc/tests/base/stdio.h 20 Oct 2003 19:31:44 -0000
@@ -31,6 +31,11 @@ extern int vsnprintf(char *, _hpux_size_
#endif /* HPUX11_VSNPRINTF_CHECK */
+#if defined( HPUX11_SNPRINTF_CHECK )
+extern int snprintf(char *, _hpux_size_t, const char *, ...);
+#endif /* HPUX11_SNPRINTF_CHECK */
+
+
#if defined( IRIX_STDIO_DUMMY_VA_LIST_CHECK )
extern int printf( const char *, __gnuc_va_list );
#endif /* IRIX_STDIO_DUMMY_VA_LIST_CHECK */
More information about the Gcc-patches
mailing list