-
Notifications
You must be signed in to change notification settings - Fork 3k
Separate type/constant declarations from functions in C headers #15760
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
374cd77
Separate type/constant declarations from functions in C headers
jakelishman 8d5f3bd
Update include guards
jakelishman 91b16cc
Comment on seemingly spurious mutability
jakelishman 0bfeb42
Fix typo
jakelishman 771962e
Increase explanation of stub file
jakelishman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // This code is part of Qiskit. | ||
| // | ||
| // (C) Copyright IBM 2026 | ||
| // | ||
| // This code is licensed under the Apache License, Version 2.0. You may | ||
| // obtain a copy of this license in the LICENSE.txt file in the root directory | ||
| // of this source tree or at https://www.apache.org/licenses/LICENSE-2.0. | ||
| // | ||
| // Any modifications or derivative works of this code must retain this | ||
| // copyright notice, and modified files need to carry a notice indicating | ||
| // that they have been altered from the originals. | ||
|
|
||
| #if !defined(QISKIT_H) | ||
| #define QISKIT_H | ||
|
|
||
| #if defined(QISKIT_C_PYTHON_INTERFACE) || defined(QISKIT_PYTHON_EXTENSION) | ||
| #include <Python.h> | ||
| #endif // defined(QISKIT_C_PYTHON_INTERFACE) || defined(QISKIT_PYTHON_EXTENSION) | ||
|
|
||
| #include "qiskit/attributes.h" | ||
| #include "qiskit/complex.h" | ||
| #include "qiskit/version.h" | ||
|
jakelishman marked this conversation as resolved.
|
||
|
|
||
| #include "qiskit/types.h" // Generated by cbindgen. | ||
|
|
||
| #if defined(QISKIT_PYTHON_EXTENSION) | ||
| #include "qiskit/funcs_py.h" // Generated by Qiskit's `pyext` (or stubbed out). | ||
| #else | ||
| #include "qiskit/funcs.h" // Generated by cbindgen. | ||
| #endif // QISKIT_PYTHON_EXTENSION | ||
|
|
||
| #endif // QISKIT_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||
| // This code is part of Qiskit. | ||||||
| // | ||||||
| // (C) Copyright IBM 2026 | ||||||
| // | ||||||
| // This code is licensed under the Apache License, Version 2.0. You may | ||||||
| // obtain a copy of this license in the LICENSE.txt file in the root directory | ||||||
| // of this source tree or at https://www.apache.org/licenses/LICENSE-2.0. | ||||||
| // | ||||||
| // Any modifications or derivative works of this code must retain this | ||||||
| // copyright notice, and modified files need to carry a notice indicating | ||||||
| // that they have been altered from the originals. | ||||||
|
|
||||||
| // This is a stub error file for distributions of the C API libraries that do not include the | ||||||
| // generated access to Python extension modules. It is overwritten by build scripts of the full | ||||||
| // Python package. | ||||||
|
mrossinek marked this conversation as resolved.
|
||||||
| // | ||||||
| // The top-level `qiskit.h` defines all the C API functions in a different manner if | ||||||
| // `QISKIT_PYTHON_EXTENSION` is defined. In Python-aware builds/distributions of the C API, this | ||||||
| // file is replaced by one that is safe to use in those situations. We leave this file in place | ||||||
| // with an explicit stub to provide a better explanations to users who have a version of the C API | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Either this or remove the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good catch -- maybe Jake can just add this to one of the follow up PRs. |
||||||
| // without Python support; the alternative is a preprocessor "file not found" error. | ||||||
|
|
||||||
| #error This Qiskit distribution does not include the ability to define Python extension modules. \ | ||||||
| Use `qiskit` as a Python-package build dependency. | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.