_POSIX_C_SOURCE redefinition warning with python 2.3 and boost-1.31.0

Sorry if this has been mentioned before. the following patch against boost-1.31.0 silences the warnings on linux, but I have not tested that there are no side-effects on other compilers. --------------------------------START PATCH------------------------ Index: boost/python/detail/wrap_python.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/python/detail/wrap_python.hpp,v retrieving revision 1.17 diff -p -r1.17 wrap_python.hpp *** boost/python/detail/wrap_python.hpp 1 May 2003 05:19:47 -0000 1.17 --- boost/python/detail/wrap_python.hpp 1 Mar 2004 05:36:49 -0000 *************** *** 23,28 **** --- 23,29 ---- // // Python's LongObject.h helpfully #defines ULONGLONG_MAX for us, // which confuses Boost's config + // Also kill any definition of _POSIX_C_SOURCE so Python.h can determine it. // #include <limits.h> #ifndef ULONG_MAX *************** *** 34,39 **** --- 35,44 ---- #ifndef ULONGLONG_MAX # define BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED #endif + #ifdef _POSIX_C_SOURCE + # undef _POSIX_C_SOURCE + #endif + // // Get ahold of Python's version number --------------------------------END PATCH------------------------ Index: boost/python/detail/wrap_python.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/python/detail/wrap_python.hpp,v retrieving revision 1.17 diff -p -r1.17 wrap_python.hpp *** boost/python/detail/wrap_python.hpp 1 May 2003 05:19:47 -0000 1.17 --- boost/python/detail/wrap_python.hpp 1 Mar 2004 05:36:49 -0000 *************** *** 23,28 **** --- 23,29 ---- // // Python's LongObject.h helpfully #defines ULONGLONG_MAX for us, // which confuses Boost's config + // Also kill any definition of _POSIX_C_SOURCE so Python.h can determine it. // #include <limits.h> #ifndef ULONG_MAX *************** *** 34,39 **** --- 35,44 ---- #ifndef ULONGLONG_MAX # define BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED #endif + #ifdef _POSIX_C_SOURCE + # undef _POSIX_C_SOURCE + #endif + // // Get ahold of Python's version number

Peter Hornby <peterho@ned.dem.csiro.au> writes:
Sorry if this has been mentioned before. the following patch against boost-1.31.0 silences the warnings on linux, but I have not tested that there are no side-effects on other compilers.
The warnings are there for a good reason: you must include a Boost.Python header *before* you include any other system headers. This restriction was imposed by the Python developers :( http://mail.python.org/pipermail/c++-sig/2003-September/005563.html -- Dave Abrahams Boost Consulting www.boost-consulting.com

Hi,
http://mail.python.org/pipermail/c++-sig/2003-September/005563.html
Yes, I did see this. At first I thought that this had been missed in wrap_python.hpp, where limits.h is included before Python.h. Upon closer inspection the reason for not just including Python.h before limits.h becomes apparent. What I did was just bein minimalist, should be a better way..... I just need to think of it.
participants (2)
-
David Abrahams
-
Peter Hornby