File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,30 @@ defined closer to where they are useful (e.g. :c:macro:`Py_RETURN_NONE`).
105
105
Others of a more general utility are defined here. This is not necessarily a
106
106
complete listing.
107
107
108
+ .. c :macro :: PyMODINIT_FUNC
109
+
110
+ Declare an extension module ``PyInit `` initialization function. The function
111
+ return type is :c:expr: `PyObject* `. The macro declares any special linkage
112
+ declarations required by the platform, and for C++ declares the function as
113
+ ``extern "C" ``.
114
+
115
+ The initialization function must be named :samp: `PyInit_{ name } `, where
116
+ *name * is the name of the module, and should be the only non-\ ``static ``
117
+ item defined in the module file. Example::
118
+
119
+ static struct PyModuleDef spam_module = {
120
+ PyModuleDef_HEAD_INIT,
121
+ .m_name = "spam",
122
+ ...
123
+ };
124
+
125
+ PyMODINIT_FUNC
126
+ PyInit_spam(void)
127
+ {
128
+ return PyModule_Create(&spam_module);
129
+ }
130
+
131
+
108
132
.. c :macro :: Py_ABS(x)
109
133
110
134
Return the absolute value of ``x ``.
Original file line number Diff line number Diff line change @@ -855,8 +855,8 @@ Example on Linux x86-64::
855
855
At the beginning of the files, C extensions are built as built-in modules.
856
856
Extensions defined after the ``*shared* `` marker are built as dynamic libraries.
857
857
858
- The :c:macro: `PyAPI_FUNC() `, :c:macro: `PyAPI_DATA() ` and
859
- :c:macro: `PyMODINIT_FUNC ` macros of :file: `Include/pyport .h ` are defined
858
+ The :c:macro: `! PyAPI_FUNC() `, :c:macro: `! PyAPI_DATA() ` and
859
+ :c:macro: `PyMODINIT_FUNC ` macros of :file: `Include/exports .h ` are defined
860
860
differently depending if the ``Py_BUILD_CORE_MODULE `` macro is defined:
861
861
862
862
* Use ``Py_EXPORTED_SYMBOL `` if the ``Py_BUILD_CORE_MODULE `` is defined
Original file line number Diff line number Diff line change @@ -1889,7 +1889,7 @@ Changes to Python's build process and to the C API include:
1889
1889
* The :c:macro: `!DL_EXPORT ` and :c:macro: `!DL_IMPORT ` macros are now deprecated.
1890
1890
Initialization functions for Python extension modules should now be declared
1891
1891
using the new macro :c:macro: `PyMODINIT_FUNC `, while the Python core will
1892
- generally use the :c:macro: `PyAPI_FUNC ` and :c:macro: `PyAPI_DATA ` macros.
1892
+ generally use the :c:macro: `! PyAPI_FUNC ` and :c:macro: `! PyAPI_DATA ` macros.
1893
1893
1894
1894
* The interpreter can be compiled without any docstrings for the built-in
1895
1895
functions and modules by supplying :option: `!--without-doc-strings ` to the
You can’t perform that action at this time.
0 commit comments