diff options
author | Victor Stinner <vstinner@python.org> | 2022-05-27 13:05:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 13:05:35 (GMT) |
commit | 22b75d9bef1bffe82bfa1adfcbec0243c9202041 (patch) | |
tree | 2f2670227cb3db6e5209b1586c79d5ffa45145fd /Include/pymacro.h | |
parent | cb04a09d2dfd197436a11de504b92773569e19fb (diff) | |
download | cpython-22b75d9bef1bffe82bfa1adfcbec0243c9202041.zip cpython-22b75d9bef1bffe82bfa1adfcbec0243c9202041.tar.gz cpython-22b75d9bef1bffe82bfa1adfcbec0243c9202041.tar.bz2 |
gh-82616: Add Py_IS_TYPE_SIGNED() macro (#93178)
_posixsubprocess: add a static assertion to ensure that the pid_t
type is signed.
Replace _Py_IntegralTypeSigned() with _Py_IS_TYPE_SIGNED().
Diffstat (limited to 'Include/pymacro.h')
-rw-r--r-- | Include/pymacro.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h index b959eeb..0a2c342 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -150,4 +150,9 @@ // For example, "int x; _Py_RVALUE(x) = 1;" fails with a compiler error. #define _Py_RVALUE(EXPR) ((void)0, (EXPR)) +// Return non-zero if the type is signed, return zero if it's unsigned. +// Use "<= 0" rather than "< 0" to prevent the compiler warning: +// "comparison of unsigned expression in '< 0' is always false". +#define _Py_IS_TYPE_SIGNED(type) ((type)(-1) <= 0) + #endif /* Py_PYMACRO_H */ |