8000 Check for compiler warnings in test_cext on Windows by vstinner · Pull Request #121088 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Check for compiler warnings in test_cext on Windows #121088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024
Merged
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
Check for compiler warnings in test_cext on Windows
On Windows, test_cext and test_cppext now pass /WX flag to the MSC
compiler to treat all compiler warnings as errors. In verbose mode,
these tests now log the compiler commands to help debugging.

Change Py_BUILD_ASSERT_EXPR implementation on Windows to avoid a
compiler warning about an unnamed structure.
  • Loading branch information
vstinner committed Jun 27, 2024
commit d7769176ffc1e4fd0972e17bc75b7845e45973d6
3 changes: 2 additions & 1 deletion Include/pymacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
&& !defined(_MSC_VER))
# define Py_BUILD_ASSERT_EXPR(cond) \
((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \
0)
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_cext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def run_cmd(operation, cmd):
cmd = [python_exe, '-X', 'dev',
'-m', 'pip', 'install', '--no-build-isolation',
os.path.abspath(pkg_dir)]
if support.verbose:
cmd.append('-v')
run_cmd('Install', cmd)

# Do a reference run. Until we test that running python
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_cext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


SOURCE = 'extension.c'

if not support.MS_WINDOWS:
# C compiler flags for GCC and clang
CFLAGS = [
Expand All @@ -25,8 +26,11 @@
'-Werror=declaration-after-statement',
)
else:
# Don't pass any compiler flag to MSVC
CFLAGS = []
# MSVC compiler flags
CFLAGS = [
# Treat all compiler warnings as compiler errors
'/WX',
]


def main():
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_cppext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def run_cmd(operation, cmd):
cmd = [python_exe, '-X', 'dev',
'-m', 'pip', 'install', '--no-build-isolation',
os.path.abspath(pkg_dir)]
if support.verbose:
cmd.append('-v')
run_cmd('Install', cmd)

# Do a reference run. Until we test that running python
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_cppext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


SOURCE = 'extension.cpp'

if not support.MS_WINDOWS:
# C++ compiler flags for GCC and clang
CPPFLAGS = [
Expand All @@ -19,8 +20,11 @@
'-Werror',
]
else:
# Don't pass any compiler flag to MSVC
CPPFLAGS = []
# MSVC compiler flags
CPPFLAGS = [
# Treat all compiler warnings as compiler errors
'/WX',
]


def main():
Expand Down
Loading
0