summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-11-22 18:57:45 (GMT)
committerGitHub <noreply@github.com>2022-11-22 18:57:45 (GMT)
commit5252ad2b646ee7bbcccee86a42cf48bbb321a6e2 (patch)
treefe51dac6365c2d311559111f5577a13a3ac1a0e4 /Doc
parentfa6cc9e6df6c517c917cb8381c14d37096c06962 (diff)
downloadcpython-5252ad2b646ee7bbcccee86a42cf48bbb321a6e2.zip
cpython-5252ad2b646ee7bbcccee86a42cf48bbb321a6e2.tar.gz
cpython-5252ad2b646ee7bbcccee86a42cf48bbb321a6e2.tar.bz2
GH-92892: Add section about variadic functions to ctypes documentation (GH-99529)
On some platforms, and in particular macOS/arm64, the calling convention for variadic arguments is different from the regular calling convention. Add a section to the documentation to document this. (cherry picked from commit bc3a11d21ddef28047b18c0f6a5068fa9fb16da2) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/ctypes.rst20
1 files changed, 20 insertions, 0 deletions
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 9f8737b..077a205 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -373,6 +373,26 @@ that they can be converted to the required C data type::
31
>>>
+.. _ctypes-calling-variadic-functions:
+
+Calling varadic functions
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+On a lot of platforms calling variadic functions through ctypes is exactly the same
+as calling functions with a fixed number of parameters. On some platforms, and in
+particular ARM64 for Apple Platforms, the calling convention for variadic functions
+is different than that for regular functions.
+
+On those platforms it is required to specify the *argtypes* attribute for the
+regular, non-variadic, function arguments:
+
+.. code-block:: python3
+
+ libc.printf.argtypes = [ctypes.c_char_p]
+
+Because specifying the attribute does inhibit portability it is adviced to always
+specify ``argtypes`` for all variadic functions.
+
.. _ctypes-calling-functions-with-own-custom-data-types: