Skip to content

Commit 37c4a65

Browse files
miss-islingtonYashp002encukouvstinner
authored
[3.14] gh-141004: Document symbol visibility macros (PyAPI_DATA, Py_EXPORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (GH-143508) (GH-143786)
(cherry picked from commit a7ba3b1) Co-authored-by: Yashraj <yashrajpala8@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent d210c77 commit 37c4a65

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

Doc/c-api/intro.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ complete listing.
182182
Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function
183183
be inlined.
184184

185+
.. c:macro:: Py_LOCAL_SYMBOL
186+
187+
Macro used to declare a symbol as local to the shared library (hidden).
188+
On supported platforms, it ensures the symbol is not exported.
189+
190+
On compatible versions of GCC/Clang, it
191+
expands to ``__attribute__((visibility("hidden")))``.
192+
185193
.. c:macro:: Py_MAX(x, y)
186194
187195
Return the maximum value between ``x`` and ``y``.
@@ -336,6 +344,38 @@ complete listing.
336344
sizeof(array) / sizeof((array)[0])
337345

338346

347+
.. c:macro:: Py_EXPORTED_SYMBOL
348+
349+
Macro used to declare a symbol (function or data) as exported.
350+
On Windows, this expands to ``__declspec(dllexport)``.
351+
On compatible versions of GCC/Clang, it
352+
expands to ``__attribute__((visibility("default")))``.
353+
This macro is for defining the C API itself; extension modules should not use it.
354+
355+
356+
.. c:macro:: Py_IMPORTED_SYMBOL
357+
358+
Macro used to declare a symbol as imported.
359+
On Windows, this expands to ``__declspec(dllimport)``.
360+
This macro is for defining the C API itself; extension modules should not use it.
361+
362+
363+
.. c:macro:: PyAPI_FUNC(type)
364+
365+
Macro used by CPython to declare a function as part of the C API.
366+
Its expansion depends on the platform and build configuration.
367+
This macro is intended for defining CPython's C API itself;
368+
extension modules should not use it for their own symbols.
369+
370+
371+
.. c:macro:: PyAPI_DATA(type)
372+
373+
Macro used by CPython to declare a public global variable as part of the C API.
374+
Its expansion depends on the platform and build configuration.
375+
This macro is intended for defining CPython's C API itself;
376+
extension modules should not use it for their own symbols.
377+
378+
339379
.. _api-objects:
340380

341381
Objects, Types and Reference Counts

Tools/check-c-api-docs/ignored_c_api.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ Py_HasFileSystemDefaultEncoding
1818
Py_UTF8Mode
1919
# pyhash.h
2020
Py_HASH_EXTERNAL
21-
# exports.h
22-
PyAPI_DATA
23-
Py_EXPORTED_SYMBOL
24-
Py_IMPORTED_SYMBOL
25-
Py_LOCAL_SYMBOL
2621
# modsupport.h
2722
PyABIInfo_FREETHREADING_AGNOSTIC
2823
# moduleobject.h

0 commit comments

Comments
 (0)