Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit642e882

Browse files
committed
plpython: Stop undefining _POSIX_C_SOURCE, _XOPEN_SOURCE
We undefined them to avoid warnings about macro redefinitions. But we haven'tfully followed the necessary include order, since at least147c248, in2011. Recently the combination of the include order rules not being followedand undefining _POSIX_C_SOURCE started to cause a compile failure, startingwith03023a2. Undefining _POSIX_C_SOURCE hides clock_gettime(), which isreferenced in an inline function as of03023a2, whereas it was a macrobefore.After seeing some evidence that undefining _POSIX_C_SOURCE et al isn'trequired, I tried to build postgres with plpython on most of our supportedplatforms (except DragonFlyBSD and Illumos, but similar systems were tested),with/without the #undefines. No compiler warning / behavioral difference.The oldest supported python version, 3.2, defines _POSIX_C_SOURCE to 200112Lad _XOPEN_SOURCE to 600, whereas newer versions of python use 200809L/700respectively. As _POSIX_C_SOURCE/_XOPEN_SOURCE will default to the neweroperating system on most platforms, it's possible that when using python 3.2new warnings would be emitted - but that seems acceptable.It's possible that this approach won't work on some older platforms. Butgetting rid of most of the include-order complexity seems promising, and it'san easily revertible patch if we end up having to go another way.Discussion:https://postgr.es/m/20230124165814.2njc7gnvubn2amh6@awork3.anarazel.de
1 parent23c1232 commit642e882

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

‎src/pl/plpython/plpython.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,13 @@
1212
#ifndefPLPYTHON_H
1313
#definePLPYTHON_H
1414

15-
/*
16-
* Include order should be: postgres.h, other postgres headers, plpython.h,
17-
* other plpython headers. (In practice, other plpython headers will also
18-
* include this file, so that they can compile standalone.)
19-
*/
20-
#ifndefPOSTGRES_H
15+
/* postgres.h needs to be included before Python.h, as usual */
16+
#if !defined(POSTGRES_H)
2117
#error postgres.h must be included before plpython.h
18+
#elif defined(Py_PYTHON_H)
19+
#error Python.h must be included via plpython.h
2220
#endif
2321

24-
/*
25-
* Undefine some things that get (re)defined in the Python headers. They aren't
26-
* used by the PL/Python code, and all PostgreSQL headers should be included
27-
* earlier, so this should be pretty safe.
28-
*/
29-
#undef _POSIX_C_SOURCE
30-
#undef _XOPEN_SOURCE
31-
3222
/*
3323
* Python versions <= 3.8 otherwise define a replacement, causing macro
3424
* redefinition warnings.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp