Chris@16: // (C) Copyright David Abrahams 2000. Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // The author gratefully acknowleges the support of Dragon Systems, Inc., in Chris@16: // producing this work. Chris@16: Chris@16: // This file serves as a wrapper around which allows it to be Chris@16: // compiled with GCC 2.95.2 under Win32 and which disables the default MSVC Chris@16: // behavior so that a program may be compiled in debug mode without requiring a Chris@16: // special debugging build of the Python library. Chris@16: Chris@16: Chris@16: // To use the Python debugging library, #define BOOST_DEBUG_PYTHON on the Chris@16: // compiler command-line. Chris@16: Chris@16: // Revision History: Chris@16: // 05 Mar 01 Suppress warnings under Cygwin with Python 2.0 (Dave Abrahams) Chris@16: // 04 Mar 01 Rolled in some changes from the Dragon fork (Dave Abrahams) Chris@16: // 01 Mar 01 define PyObject_INIT() for Python 1.x (Dave Abrahams) Chris@16: Chris@16: #ifdef _DEBUG Chris@16: # ifndef BOOST_DEBUG_PYTHON Chris@16: # ifdef _MSC_VER Chris@16: // VC8.0 will complain if system headers are #included both with Chris@16: // and without _DEBUG defined, so we have to #include all the Chris@16: // system headers used by pyconfig.h right here. Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # endif Chris@16: # undef _DEBUG // Don't let Python force the debug library just because we're debugging. Chris@16: # define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H Chris@16: # endif Chris@16: #endif Chris@16: Chris@16: # include Chris@16: # if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION >= 740 Chris@16: # undef _POSIX_C_SOURCE Chris@16: # undef _XOPEN_SOURCE Chris@16: # undef HAVE_STDINT_H // undo Python 2.5.1 define Chris@16: # endif Chris@16: Chris@16: // Chris@16: // Python's LongObject.h helpfully #defines ULONGLONG_MAX for us, Chris@16: // which confuses Boost's config Chris@16: // Chris@16: #include Chris@16: #ifndef ULONG_MAX Chris@16: # define BOOST_PYTHON_ULONG_MAX_UNDEFINED Chris@16: #endif Chris@16: #ifndef LONGLONG_MAX Chris@16: # define BOOST_PYTHON_LONGLONG_MAX_UNDEFINED Chris@16: #endif Chris@16: #ifndef ULONGLONG_MAX Chris@16: # define BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED Chris@16: #endif Chris@16: Chris@16: // Chris@16: // Get ahold of Python's version number Chris@16: // Chris@16: #include Chris@16: Chris@16: #if PY_MAJOR_VERSION<2 || PY_MAJOR_VERSION==2 && PY_MINOR_VERSION<2 Chris@16: #error Python 2.2 or higher is required for this version of Boost.Python. Chris@16: #endif Chris@16: Chris@16: // Chris@16: // Some things we need in order to get Python.h to work with compilers other Chris@16: // than MSVC on Win32 Chris@16: // Chris@16: #if defined(_WIN32) || defined(__CYGWIN__) Chris@16: # if defined(__GNUC__) && defined(__CYGWIN__) Chris@16: Chris@16: # define SIZEOF_LONG 4 Chris@16: Chris@16: # if PY_MAJOR_VERSION < 2 || PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 2 Chris@16: Chris@16: typedef int pid_t; Chris@16: Chris@16: # define WORD_BIT 32 Chris@16: # define hypot _hypot Chris@16: # include Chris@16: Chris@16: # if PY_MAJOR_VERSION < 2 Chris@16: # define HAVE_CLOCK Chris@16: # define HAVE_STRFTIME Chris@16: # define HAVE_STRERROR Chris@16: # endif Chris@16: Chris@16: # define NT_THREADS Chris@16: Chris@16: # ifndef NETSCAPE_PI Chris@16: # define USE_SOCKET Chris@16: # endif Chris@16: Chris@16: # ifdef USE_DL_IMPORT Chris@16: # define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE Chris@16: # endif Chris@16: Chris@16: # ifdef USE_DL_EXPORT Chris@16: # define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE Chris@16: # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE Chris@16: # endif Chris@16: Chris@16: # define HAVE_LONG_LONG 1 Chris@16: # define LONG_LONG long long Chris@16: # endif Chris@16: Chris@16: # elif defined(__MWERKS__) Chris@16: Chris@16: # ifndef _MSC_VER Chris@16: # define PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H 1 Chris@16: # define _MSC_VER 900 Chris@16: # endif Chris@16: Chris@16: # undef hypot // undo the evil #define left by Python. Chris@16: Chris@16: # elif defined(__BORLANDC__) Chris@16: # undef HAVE_HYPOT Chris@16: # define HAVE_HYPOT 1 Chris@16: # endif Chris@16: Chris@16: #endif // _WIN32 Chris@16: Chris@16: #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2 Chris@16: # include Chris@16: #else Chris@16: # include Chris@16: #endif Chris@16: Chris@16: #ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED Chris@16: # undef ULONG_MAX Chris@16: # undef BOOST_PYTHON_ULONG_MAX_UNDEFINED Chris@16: #endif Chris@16: Chris@16: #ifdef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED Chris@16: # undef LONGLONG_MAX Chris@16: # undef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED Chris@16: #endif Chris@16: Chris@16: #ifdef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED Chris@16: # undef ULONGLONG_MAX Chris@16: # undef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED Chris@16: #endif Chris@16: Chris@16: #ifdef PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H Chris@16: # undef _MSC_VER Chris@16: #endif Chris@16: Chris@16: #ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H Chris@16: # undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H Chris@16: # define _DEBUG Chris@16: # ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H Chris@16: # undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H Chris@16: # undef _CRT_NOFORCE_MANIFEST Chris@16: # endif Chris@16: #endif Chris@16: Chris@16: #if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2 Chris@16: # define PyObject_INIT(op, typeobj) \ Chris@16: ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) Chris@16: #endif Chris@16: Chris@16: // Define Python 3 macros for Python 2.x Chris@16: #if PY_VERSION_HEX < 0x02060000 Chris@16: Chris@16: # define Py_TYPE(o) (((PyObject*)(o))->ob_type) Chris@16: # define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt) Chris@16: # define Py_SIZE(o) (((PyVarObject*)(o))->ob_size) Chris@16: Chris@16: # define PyVarObject_HEAD_INIT(type, size) \ Chris@16: PyObject_HEAD_INIT(type) size, Chris@16: Chris@16: #endif Chris@16: Chris@16: Chris@16: #ifdef __MWERKS__ Chris@16: # pragma warn_possunwant off Chris@16: #elif _MSC_VER Chris@16: # pragma warning(disable:4786) Chris@16: #endif Chris@16: Chris@16: #if defined(HAVE_LONG_LONG) Chris@16: # if defined(PY_LONG_LONG) Chris@16: # define BOOST_PYTHON_LONG_LONG PY_LONG_LONG Chris@16: # elif defined(LONG_LONG) Chris@16: # define BOOST_PYTHON_LONG_LONG LONG_LONG Chris@16: # else Chris@16: # error "HAVE_LONG_LONG defined but not PY_LONG_LONG or LONG_LONG" Chris@16: # endif Chris@16: #endif