• David Vierra's avatar
    Rewrite __Pyx_sst_abs using only preprocessor macros, and add a case for 64-bit MSVC · 2e1f7fdf
    David Vierra authored
    Comparing `sizeof(Py_ssize_t)` to different sizes at compile time results in warnings or errors when the C++ compiler tries to find a function matching `abs(value)` (Per the standard library spec, no functions match if `ssize_t` is a typedef of `long long`). Luckily, `pyport.h` provides some SIZEOF macros we can use at preprocess time. __Pyx_sst_abs is now conditionally defined to a much shorter expression.
    
    64-bit MSVC is one case where `ssize_t` is a `long long`. Instead of falling back to `((value<0) ? -value : value))`, I added a check for 64-bit MSVC that calls the MS-specific function `_abs64(long long)`
    
    This change also includes the change given by PR #402, improved with a check against the available C++ version as `std::abs` is only available on C++11.
    2e1f7fdf
TypeConversion.c 26.1 KB