File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -107,9 +107,27 @@ complete listing.
107107
108108.. c :macro :: PyMODINIT_FUNC
109109
110- Declare an extension module ``PyInit `` initialization function. The return
111- type is :c:expr: `PyObject* `. The macro should only be used in the Python C
112- API.
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 :c:func: `!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+
113131
114132.. c :macro :: Py_ABS(x)
115133
You can’t perform that action at this time.
0 commit comments