Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/cpython/pyatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ static inline void _Py_atomic_fence_release(void);
# define Py_ATOMIC_GCC_H
# include "pyatomic_gcc.h"
# undef Py_ATOMIC_GCC_H
#elif _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_ATOMICS__)
#elif defined(_Py_STDC_VERSION) && _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_ATOMICS__)
# define Py_ATOMIC_STD_H
# include "pyatomic_std.h"
# undef Py_ATOMIC_STD_H
Expand Down
2 changes: 1 addition & 1 deletion Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ extern "C" {
#ifdef WITH_THREAD
# ifdef thread_local
# define _Py_thread_local thread_local
# elif _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_THREADS__)
# elif defined(_Py_STDC_VERSION) && _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_THREADS__)
# define _Py_thread_local _Thread_local
# elif defined(_MSC_VER) /* AKA NT_THREADS */
# define _Py_thread_local __declspec(thread)
Expand Down
10 changes: 10 additions & 0 deletions Lib/test/test_cext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ def test_build_abi3t(self):
# Test with Py_TARGET_ABI3T
self.check_build('_test_cext_abi3t', abi3t=True)

# gh-154643: Test that headers don't use undefined macros in #if
@unittest.skipIf(support.MS_WINDOWS, "MSVC doesn't support -Werror=undef")
def test_build_werror_undef(self):
self.check_build('_test_cext_undef', extra_cflags='-Werror=undef')
Comment thread
hroncok marked this conversation as resolved.
Resolved


class TestPublicCpp(BaseTests, unittest.TestCase):
LANGUAGE = 'C++'
Expand Down Expand Up @@ -174,6 +179,11 @@ def test_build_abi3t(self):
# Test with Py_TARGET_ABI3T
self.check_build('_test_cppext_abi3t', abi3t=True)

# gh-154643: Test that headers don't use undefined macros in #if
@unittest.skipIf(support.MS_WINDOWS, "MSVC doesn't support -Werror=undef")
def test_build_werror_undef(self):
self.check_build('_testcppext_undef', extra_cflags='-Werror=undef')


class TestInternalC(BaseTests, unittest.TestCase):
LANGUAGE = 'C'
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_cext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

# Ask for strict(er) compliance with the standard
'-pedantic-errors',

# gh-154643: Headers should not use undefined macros in #if
'-Werror=undef',
]
if not support.Py_GIL_DISABLED:
PUBLIC_CFLAGS.append(
Expand Down Expand Up @@ -94,6 +97,9 @@

# We also use `long long`, a C++11 feature we can enable individually.
'-Wno-long-long',

# gh-154643: Headers should not use undefined macros in #if
'-Werror=undef',
]
INTERNAL_CXXFLAGS = [
# Do not complain about unused parameteres in the internal C API
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In ``pyport.h`` and ``pyatomic.h`` don't use ``_Py_STDC_VERSION`` when it is
not defined, fixing build errors for C or C++ code built with ``-Werror=undef``.
Loading