I spent a little time this morning looking into these warnings I get when
building mpl from source, for example:
···
-----------------------------------------------------
In file included from /usr/include/python2.4/Python.h:13,
from ./CXX/Objects.hxx:9,
from ./CXX/Extensions.hxx:19,
from src/_backend_agg.h:8,
from src/_wxagg.cpp:48:
/usr/include/python2.4/pyconfig.h:838:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/features.h:8,
from /usr/include/gentoo-multilib/amd64/string.h:26,
from /usr/include/string.h:8,
from /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/g++-v4/cstring:53,
from src/_wxagg.cpp:38:
/usr/include/gentoo-multilib/amd64/features.h:154:1: warning: this is the
location of the previous definition
-----------------------------------------------------
These warnings come from the "#include Python.h" statements, although I
haven't been able to track down the exact reason. (This problem was discussed
on python-dev,
http://mail.python.org/pipermail/python-dev/2005-June/054214.html, but I
wasn't able to improve mpl's code based on that discussion.) The following
patch allows mpl to build without warnings on my system (it is hackish, I
don't intend to commit it.) Would anyone please care to comment?
Darren
Index: src/_gtkagg.cpp
--- src/_gtkagg.cpp (revision 2706)
+++ src/_gtkagg.cpp (working copy)
@@ -6,6 +6,9 @@
#include <utility>
#include <fstream>
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
#include <pygobject.h>
#include <pygtk/pygtk.h>
Index: src/_image.cpp
--- src/_image.cpp (revision 2706)
+++ src/_image.cpp (working copy)
@@ -5,6 +5,10 @@
#include <cstdio>
#include <png.h>
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
#include "Python.h" //after png.h due to setjmp bug
#include <string>
Index: CXX/Objects.hxx
--- CXX/Objects.hxx (revision 2706)
+++ CXX/Objects.hxx (working copy)
@@ -6,6 +6,10 @@
#ifndef __CXX_Objects__h
#define __CXX_Objects__h
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
#include "Python.h"
#include "CXX/Version.hxx"
#include "CXX/Config.hxx"