pythoncapi-compat icon indicating copy to clipboard operation
pythoncapi-compat copied to clipboard

Support including two different versions of the header: #ifdef guard per function

Open vstinner opened this issue 4 years ago • 1 comments

If you include an old version of pythoncapi_compat.h header file and then include a new version of the header file, the new header is ignored by the global guard:

#ifndef PYTHONCAPI_COMPAT
#define PYTHONCAPI_COMPAT

It would be nice to support including multiple versions of the header file.

Use case:

  • a library has its own OLD pythoncapi_compat.h copy
  • an application uses this library and has a NEW header copy

The expected behavior is that the application gets the new definitions of the new copy, even if the old copy was already included.

The pybind11 project requires to support this use case: https://github.com/pybind/pybind11/pull/2932 to be able to use pythoncapi_compat.h.

The idea is to have guards per function, rather than having a single global guard.

I'm not sure how the compiler selects which header file is used if there are two copies in the include directory paths.

vstinner avatar Dec 06 '21 12:12 vstinner

cc @erlend-aasland @corona10

vstinner avatar Dec 06 '21 12:12 vstinner

I lost track of this issue. I prefer to close it for now.

vstinner avatar Sep 03 '24 12:09 vstinner