Skip to content

Instantly share code, notes, and snippets.

@catern
Created November 13, 2019 16:44
Show Gist options
  • Save catern/835a12f00688a184e5234e92553053f0 to your computer and use it in GitHub Desktop.
Save catern/835a12f00688a184e5234e92553053f0 to your computer and use it in GitHub Desktop.
from cffi import FFI
def compile_stat_ffi_with_cdef(name, cdef):
ffi = FFI()
ffi.set_source(
name, """
#include <sys/stat.h>
""")
ffi.cdef(cdef)
print("compiled to", ffi.compile())
compile_stat_ffi_with_cdef("ffi1", """
struct stat {
unsigned long st_dev;
...;
};
""")
compile_stat_ffi_with_cdef("ffi2", """
struct stat {
unsigned short st_dev;
...;
};
""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment