]> Savannah Git Hosting - gnulib.git/commitdiff
stdio: Don't redefine gets when using C++
authorJonathan Perkin <jperkin@joyent.com>
Thu, 4 Jun 2015 11:10:34 +0000 (12:10 +0100)
committerEric Blake <eblake@redhat.com>
Fri, 5 Jun 2015 16:25:01 +0000 (10:25 -0600)
We've hit this failure a few times in pkgsrc with packages which embed gnulib,
an example being the latest gnutls:

  ../../src/gl/stdio.h:1034:1: error: 'char* gets(char*)' conflicts with a previous declaration
   _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
   ^

  /opt/tools/gcc49/lib/gcc/x86_64-sun-solaris2.11/4.9.2/include-fixed/iso/stdio_iso.h:259:14: note: previous declaration 'char* std::gets(char*)'
   extern char *gets(char *);
                ^

Full build log is here:

  http://us-east.manta.joyent.com/pkgsrc/public/reports/upstream-trunk32/20150602.2233/gnutls-3.3.15/build.log

We've fixed it a few different ways over time:

  https://github.com/joyent/pkgsrc/blob/joyent/release/2015Q1/devel/m4/patches/patch-lib_stdio.in.h
  https://github.com/joyent/pkgsrc/blob/joyent/release/2015Q1/math/octave/patches/patch-libgnu_stdio.in.h
  https://github.com/joyent/pkgsrc/blob/joyent/release/2015Q1/security/gnutls/patches/patch-gl_stdio.in.h

but the cleanest fix appears to be the last, so I am proposing it here for
inclusion upstream.

Message-Id: <20150604111034.GG66573@joyent.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/stdio.in.h

index ed6803264bdd50d057f2f407bbeb6ac854f8978f..296ccaf1417292177380b5bc91ba43f79345af0c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-05  Jonathan Perkin  <jperkin@joyent.com>  (tiny change)
+
+       stdio: Don't redefine gets when using C++
+       * lib/stdio.in.h (gets): Disable warning on C++.
+
 2015-06-05  Paul Eggert  <eggert@cs.ucla.edu>
 
        acl-permissions: port to older AIX, C89 HP-UX
index fa6b59536901814f6713c9813924d906d7ad38f5..476dee1c581d07c9a23089a77d53bd9f3aab4dde 100644 (file)
@@ -723,11 +723,10 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
    so any use of gets warrants an unconditional warning; besides, C11
    removed it.  */
 #undef gets
-#if HAVE_RAW_DECL_GETS
+#if HAVE_RAW_DECL_GETS && !defined __cplusplus
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 #endif
 
-
 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
 struct obstack;
 /* Grow an obstack with formatted output.  Return the number of