8000 Support including two different versions of the header: #ifdef guard per function · Issue #14 · python/pythoncapi-compat · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vstinner opened this issue Dec 6, 2021 · 2 comments

Comments

@vstinner
Copy link
Member
vstinner commented Dec 6, 2021

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: pybind/pybind11#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
Copy link
Member Author
vstinner commented Dec 6, 2021

cc @erlend-aasland @corona10

@vstinner
Copy link
Member Author
vstinner commented Sep 3, 2024

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

@vstinner vstinner closed this as completed Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0