FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-92892: Add section about variadic functions to ctypes documentation by ronaldoussoren · Pull Request #99529 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 20 additions & 0 deletions Doc/library/ctypes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,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:

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document that calling variadic functions with ctypes requires special care on macOS/arm64 (and possibly other platforms).

Back | FazBrowse Home | New Git URL