https://github.com/python/cpython/commit/ef4b69d2becf49daaea21eb04effee81328a0393 commit: ef4b69d2becf49daaea21eb04effee81328a0393 branch: main author: Victor Stinner <vstin...@python.org> committer: vstinner <vstin...@python.org> date: 2024-09-06T15:52:07+02:00 summary:
gh-123747: Avoid static_assert() in internal header files (#123779) files: M Include/internal/pycore_code.h M Include/internal/pycore_long.h diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 112e880f924727..57e0a14bb9b5bd 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -543,8 +543,9 @@ write_location_entry_start(uint8_t *ptr, int code, int length) #define ADAPTIVE_COOLDOWN_BACKOFF 0 // Can't assert this in pycore_backoff.h because of header order dependencies -static_assert(SIDE_EXIT_INITIAL_VALUE > ADAPTIVE_COOLDOWN_VALUE, - "Cold exit value should be larger than adaptive cooldown value"); +#if SIDE_EXIT_INITIAL_VALUE <= ADAPTIVE_COOLDOWN_VALUE +# error "Cold exit value should be larger than adaptive cooldown value" +#endif static inline _Py_BackoffCounter adaptive_counter_bits(uint16_t value, uint16_t backoff) { diff --git a/Include/internal/pycore_long.h b/Include/internal/pycore_long.h index 2c7ca6723c1973..a516a3edd12203 100644 --- a/Include/internal/pycore_long.h +++ b/Include/internal/pycore_long.h @@ -178,8 +178,12 @@ PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *); * we define them to the numbers in both places and then assert that * they're the same. */ -static_assert(SIGN_MASK == _PyLong_SIGN_MASK, "SIGN_MASK does not match _PyLong_SIGN_MASK"); -static_assert(NON_SIZE_BITS == _PyLong_NON_SIZE_BITS, "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS"); +#if SIGN_MASK != _PyLong_SIGN_MASK +# error "SIGN_MASK does not match _PyLong_SIGN_MASK" +#endif +#if NON_SIZE_BITS != _PyLong_NON_SIZE_BITS +# error "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS" +#endif /* All *compact" values are guaranteed to fit into * a Py_ssize_t with at least one bit to spare. _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com