Suppose we're writing a CPython extension module in C.
When defining an extension, we are required to supply a PyMODINIT_FUNC PyInit_<module_name>(void). Nowhere in this declaration is a native calling convention specified.
Whether on Linux or on Windows, how can the extension developer ensure that the PyInit_ function is compiled using the correct calling convention, so that the interpreter calls it successfuly during runtime? Is there some magic in the Python headers that takes care of this for us? Or something else?
The same question applies to native functions contained in the extension module, and exposed to Python wrapped as function objects. How do we ensure that these are compiled in a manner compatible with the Python interpreter calling convention?
The default calling convention is automatically made by the compiler. PyMODINIT_FUNC is either void (in Python 2) or PyObject * (in Python 3), nothing more.
The Python dynamic module loader uses the default convention of the platform (not that it has any jurisdiction over that; it's to the platform).
How is a C extension compiled with the correct native calling convention?