When I wrote a PR to use the C header file pythoncapi_compat.h in the datatable C++ project, I got multiple C++ compiler warnings in static inline functions and in some macros:
https://github.com/h2oai/datatable/pull/3231#issuecomment-1032864790
* Usage of NULL
* Usage of "old-style cast" like (ssize_t)1 or (PyObject*)obj
I solved this issue in pythoncapi_compat.h by using reinterpret_cast and nullptr:
* https://github.com/python/pythoncapi_compat/commit/347746379f79fa091017e23427932c9f9980234d
* https://github.com/python/pythoncapi_compat/pull/18
* https://github.com/h2oai/datatable/pull/3237
By the way, pythoncapi_compat.h no longer uses "module":
https://github.com/python/pythoncapi_compat/pull/22
The Python C API has similar issues, but warnings about NULL and old-style cast depend on the C++ compiler flags:
* -Wzero-as-null-pointer-constant
* -Wold-style-cast |