add flags to cffi compile process

2.1k views Asked by At

I use cffi module to wrap a simple c code. the problem is, I need to add a flag to make it compile (std=c99). currently I have something like that:

from cffi import FFI
ffibuilder = FFI()
with open("test.c", 'r') as f:
    ffibuilder.set_source("mymodule", f.read()) 
with open("test.h", 'r') as f:
    ffibuilder.cdef(f.read())
if __name__ == "__main__":
    ffibuilder.compile(verbose=True)

The problem is, that cffi calls gcc by itself and I want to add std=c99 to the flags it calls gcc with. Any parameter I am missing?

(Note: I can change gcc command itself or run the gcc command cffi uses myself, I am wondering if I am missing some correct way to do it)

1

There are 1 answers

0
tal On BEST ANSWER

I eventually found the answer:

set_source accepts extra_compile_args argument: so you can call:

ffibuilder.set_source(..., extra_compile_args=["-std=c99"])