Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
first exports
  • Loading branch information
Yashp002 committed Jan 7, 2026
commit 1cfd6837e6d580ac62d4fa860b32bdd79743c48d
33 changes: 33 additions & 0 deletions Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,39 @@ complete listing.
sizeof(array) / sizeof((array)[0])


.. c:macro:: Py_EXPORTED_SYMBOL

Macro used to declare a symbol (function or data) as exported from a shared library.
On Windows, this expands to ``__declspec(dllexport)``.
On other platforms with visibility support, it
Comment thread
Yashp002 marked this conversation as resolved.
Outdated
expands to ``__attribute__((visibility("default")))``.


.. c:macro:: Py_IMPORTED_SYMBOL

Macro used to declare a symbol as imported from a shared library.
On Windows, this expands to ``__declspec(dllimport)``.
On other platforms, it is usually empty or standard visibility.
Comment thread
Yashp002 marked this conversation as resolved.
Outdated


.. c:macro:: PyAPI_DATA(type)
Comment thread
encukou marked this conversation as resolved.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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

Comment thread
Yashp002 marked this conversation as resolved.
Outdated

Example usage::

PyAPI_DATA(PyObject *) _Py_NoneStruct;


.. c:macro:: Py_LOCAL_SYMBOL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this next to the other Py_LOCAL macros, and ideally match their style?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess Py_ALWAYS_INLINE, Py_DEPRECATED, Py_LOCAL, Py_LOCAL_INLINE, all of these, and possibly Py_UNUSED, could be moved to a new section. But that can be in a new PR.


Macro used to declare a symbol as local to the shared library (hidden).
It ensures the symbol is not exported.
On platforms with visibility support, it
expands to ``__attribute__((visibility("hidden")))``.

.. _api-objects:

Objects, Types and Reference Counts
Expand Down
Loading