This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix compilation warnings triggered by Python's pyerrors.h


I get warnings like below compiling GDB 7.5.91 with MinGW:

     In file included from d:/usr/Python26/include/Python.h:120:0,
		      from python/python-internal.h:50,
		      from varobj.c:41:
     d:/usr/Python26/include/pyerrors.h:316:0: warning: "snprintf" redefined [enabled by default]
     In file included from ./common/gdb_locale.h:27:0,
		      from defs.h:66,
		      from varobj.c:18:
     d:\usr\bin\../lib/gcc/mingw32/4.7.2/../../../../include/libintl.h:353:0: note: this is the location of the previous definition

   This happens because Python's pyerrors.h has this:

     #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
     # define HAVE_SNPRINTF
     # define snprintf _snprintf
     # define vsnprintf _vsnprintf
     #endif

   But libintl.h has this:

     #undef snprintf
     #define snprintf libintl_snprintf
     extern int snprintf (char *, size_t, const char *, ...);
     #undef vsnprintf
     #define vsnprintf libintl_vsnprintf
     extern int vsnprintf (char *, size_t, const char *, va_list);

Suggested work-around: Define HAVE_SNPRINTF in defs.h:

--- gdb/defs.h~0	2013-02-04 14:57:44.000000000 +0200
+++ gdb/defs.h	2013-03-13 13:39:22.245759200 +0200
@@ -58,6 +58,11 @@
 
 #include <fcntl.h>
 
+/* A kludge to avoid redefinition of snprintf on Windows by pyerrors.h.  */
+#if defined(_WIN32) && defined(HAVE_DECL_SNPRINTF)
+#define HAVE_SNPRINTF 1
+#endif
+
 /* First include ansidecl.h so we can use the various macro definitions
    here and in all subsequent file inclusions.  */
 
OK to commit?  Can this go to the release branch as well?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]