Fix header inclusion order in c.h.
[pgsql.git] / src / pl / plpython / plpython_system.h
blob036d339bf83d0ab06ea89d7555519ef11a900c31
1 /*-------------------------------------------------------------------------
3 * plpython_system.h - pull in Python's system header files
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.
10 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
11 * Portions Copyright (c) 1994, Regents of the University of California
13 * src/pl/plpython/plpython_system.h
15 *-------------------------------------------------------------------------
17 #ifndef PLPYTHON_SYSTEM_H
18 #define PLPYTHON_SYSTEM_H
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.
26 #ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER
27 #pragma GCC system_header
28 #endif
31 * Python versions <= 3.8 otherwise define a replacement, causing macro
32 * redefinition warnings.
34 #define HAVE_SNPRINTF 1
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
53 #endif /* PLPYTHON_SYSTEM_H */