Skip to content

Commit 2285724

Browse files
committed
include Python.h first in extension code; patch by Jason Grout.
This cleans up the preprocessor directives and allows compilation on Solaris. A preprocessor directive is added to keep png.h from failing on Linux because Python.h has caused setjmp.h to be included. svn path=/branches/v1_0_maint/; revision=8706
1 parent 097697f commit 2285724

File tree

4 files changed

+13
-32
lines changed

4 files changed

+13
-32
lines changed

CXX/WrapPython.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,12 @@
3838
#ifndef __PyCXX_wrap_python_hxx__
3939
#define __PyCXX_wrap_python_hxx__
4040

41+
/* Python API mandates Python.h is included *first* */
42+
#include "Python.h"
43+
4144
// On some platforms we have to include time.h to get select defined
4245
#if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) && !defined(_WIN64)
4346
#include <sys/time.h>
4447
#endif
4548

46-
// Prevent multiple conflicting definitions of swab from stdlib.h and unistd.h
47-
#if defined(__sun) || defined(sun)
48-
#if defined(_XPG4)
49-
#undef _XPG4
50-
#endif
51-
#if defined(_XPG3)
52-
#undef _XPG3
53-
#endif
54-
#endif
55-
56-
// Python.h will redefine these and generate warning in the process
57-
#undef _XOPEN_SOURCE
58-
#undef _POSIX_C_SOURCE
59-
60-
// pull in python definitions
61-
#include <Python.h>
62-
6349
#endif

src/_backend_agg.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* A rewrite of _backend_agg using PyCXX to handle ref counting, etc..
22
*/
3-
#include <png.h>
43

5-
// To remove a gcc warning
6-
#ifdef _POSIX_C_SOURCE
7-
#undef _POSIX_C_SOURCE
8-
#endif
4+
/* Python API mandates Python.h is included *first* */
5+
#include "Python.h"
6+
7+
#define PNG_SKIP_SETJMP_CHECK
8+
#include <png.h>
99

1010
#include "ft2font.h"
1111
#include "_image.h"

src/_image.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// To remove a gcc warning
2-
#ifdef _POSIX_C_SOURCE
3-
#undef _POSIX_C_SOURCE
4-
#endif
5-
1+
/* Python API mandates Python.h is included *first* */
62
#include "Python.h"
73
#include <string>
84

src/_png.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#include <png.h>
1+
/* Python API mandates Python.h is included *first* */
2+
#include "Python.h"
23

3-
// To remove a gcc warning
4-
#ifdef _POSIX_C_SOURCE
5-
#undef _POSIX_C_SOURCE
6-
#endif
4+
#define PNG_SKIP_SETJMP_CHECK
5+
#include <png.h>
76

87
// TODO: Un CXX-ify this module
98
#include "CXX/Extensions.hxx"

0 commit comments

Comments
 (0)