mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
gh-107298: Document PyMODINIT_FUNC macro (#109236)
Document PyMODINIT_FUNC macro. Remove links to PyAPI_FUNC() and PyAPI_DATA() macros since they are not documented. These macros should only be used to define the Python C API. They should not be used outside Python code base.
This commit is contained in:
parent
1f885df2a5
commit
d7a27e527d
3 changed files with 27 additions and 3 deletions
|
|
@ -105,6 +105,30 @@ defined closer to where they are useful (e.g. :c:macro:`Py_RETURN_NONE`).
|
|||
Others of a more general utility are defined here. This is not necessarily a
|
||||
complete listing.
|
||||
|
||||
.. c:macro:: PyMODINIT_FUNC
|
||||
|
||||
Declare an extension module ``PyInit`` initialization function. The function
|
||||
return type is :c:expr:`PyObject*`. The macro declares any special linkage
|
||||
declarations required by the platform, and for C++ declares the function as
|
||||
``extern "C"``.
|
||||
|
||||
The initialization function must be named :samp:`PyInit_{name}`, where
|
||||
*name* is the name of the module, and should be the only non-\ ``static``
|
||||
item defined in the module file. Example::
|
||||
|
||||
static struct PyModuleDef spam_module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
.m_name = "spam",
|
||||
...
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit_spam(void)
|
||||
{
|
||||
return PyModule_Create(&spam_module);
|
||||
}
|
||||
|
||||
|
||||
.. c:macro:: Py_ABS(x)
|
||||
|
||||
Return the absolute value of ``x``.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue