PostgreSQL Source Code  git master
plpython_system.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * plpython_system.h - pull in Python's system header files
4  *
5  * We break this out as a separate header file to precisely control
6  * the scope of the "system_header" pragma. No Postgres-specific
7  * declarations should be put here. However, we do include some stuff
8  * that is meant to prevent conflicts between our code and Python.
9  *
10  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
11  * Portions Copyright (c) 1994, Regents of the University of California
12  *
13  * src/pl/plpython/plpython_system.h
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef PLPYTHON_SYSTEM_H
18 #define PLPYTHON_SYSTEM_H
19 
20 /*
21  * Newer versions of the Python headers trigger a lot of warnings with our
22  * preferred compiler flags (at least -Wdeclaration-after-statement is known
23  * to be problematic). The system_header pragma hides warnings from within
24  * the rest of this file, if supported.
25  */
26 #ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER
27 #pragma GCC system_header
28 #endif
29 
30 /*
31  * Python versions <= 3.8 otherwise define a replacement, causing macro
32  * redefinition warnings.
33  */
34 #define HAVE_SNPRINTF 1
35 
36 #if defined(_MSC_VER) && defined(_DEBUG)
37 /* Python uses #pragma to bring in a non-default libpython on VC++ if
38  * _DEBUG is defined */
39 #undef _DEBUG
40 /* Also hide away errcode, since we load Python.h before postgres.h */
41 #define errcode __msvc_errcode
42 #include <Python.h>
43 #undef errcode
44 #define _DEBUG
45 #elif defined (_MSC_VER)
46 #define errcode __msvc_errcode
47 #include <Python.h>
48 #undef errcode
49 #else
50 #include <Python.h>
51 #endif
52 
53 #endif /* PLPYTHON_SYSTEM_H */