-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-141004: Document symbol visibility macros (PyAPI_DATA, Py_EXPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) #143508
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
Changes from 9 commits
1cfd683
0164c79
d0c5c25
d3e69b6
68269d3
113ff5e
9eb597b
6b9df7f
26cffa2
6c59e9b
2f24241
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,6 +222,14 @@ complete listing. | |
| Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function | ||
| be inlined. | ||
|
|
||
| .. c:macro:: Py_LOCAL_SYMBOL | ||
|
|
||
| Macro used to declare a symbol as local to the shared library (hidden). | ||
| On supported platforms, it ensures the symbol is not exported. | ||
|
|
||
| On compatible versions of GCC/Clang, it | ||
| expands to ``__attribute__((visibility("hidden")))``. | ||
|
|
||
| .. c:macro:: Py_MAX(x, y) | ||
|
|
||
| Return the maximum value between ``x`` and ``y``. | ||
|
|
@@ -376,6 +384,43 @@ complete listing. | |
| sizeof(array) / sizeof((array)[0]) | ||
|
|
||
|
|
||
| .. c:macro:: Py_EXPORTED_SYMBOL | ||
|
|
||
| Macro used to declare a symbol (function or data) as exported. | ||
| On Windows, this expands to ``__declspec(dllexport)``. | ||
| On compatible versions of GCC/Clang, it | ||
| expands to ``__attribute__((visibility("default")))``. | ||
| This macro is for defining the C API itself; extension modules should not use it. | ||
|
|
||
|
|
||
| .. c:macro:: Py_IMPORTED_SYMBOL | ||
|
|
||
| Macro used to declare a symbol as imported. | ||
| On Windows, this expands to ``__declspec(dllimport)``. | ||
| This macro is for defining the C API itself; extension modules should not use it. | ||
|
|
||
|
|
||
| .. c:macro:: PyAPI_FUNC(type) | ||
|
|
||
| Macro used by CPython to declare a function as part of the C API. | ||
| Its expansion depends on the platform and build configuration. | ||
| This macro is intended for defining CPython's C API itself; | ||
| extension modules should not use it for their own symbols. | ||
|
|
||
|
|
||
| .. c:macro:: PyAPI_DATA(type) | ||
|
|
||
| Macro used to declare a public global variable. | ||
| It expands to ``extern Py_EXPORTED_SYMBOL type`` or ``extern Py_IMPORTED_SYMBOL type`` | ||
| depending on whether the core is being built or used. | ||
|
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. I would also add: "This macro is intended for defining CPython's C API itself; extension modules should not use it for their own symbols."
Contributor
Author
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. gonna push a PR for the manual changes in a bit yes, thank you for the corrections
Yashp002 marked this conversation as resolved.
Outdated
|
||
| This macro is intended for defining CPython's C API itself; | ||
| extension modules should not use it for their own symbols. | ||
|
|
||
| Example usage:: | ||
|
|
||
| PyAPI_DATA(const unsigned long) Py_Version; | ||
|
Yashp002 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| .. _api-objects: | ||
|
|
||
| Objects, Types and Reference Counts | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.