# Pastebin wABvdfFI dev@MacBook-Pro:~/tmp$ cat x.c #include #include // Variadic function to add numbers int add_numbers(int n, ...) { int Sum = 0; // Declaring pointer to the // argument list va_list ptr; // Initializing argument to the // list pointer va_start(ptr, n); for (int i = 0; i < n; i++) // Accessing current variable // and pointing to next one Sum += va_arg(ptr, int); // Ending argument list traversal va_end(ptr); return Sum; } dev@MacBook-Pro:~/tmp$ cat x.,py cat: x.,py: No such file or directory dev@MacBook-Pro:~/tmp$ cat x.py import ctypes lib = ctypes.CDLL("/Users/dev/tmp/x.dylib") add = lib.add_numbers add.argtypes = (ctypes.c_int, ctypes.c_int, ctypes.c_int) add.restype = ctypes.c_int print(add(2, 3, 5)) dev@MacBook-Pro:~/tmp$ python x.py 19665968 dev@MacBook-Pro:~/tmp$