I am trying to use python-cffi to wrap C code. The following example_build.py shows an attempt to wrap lstat() call:
import cffi
ffi = cffi.FFI()
ffi.set_source("_cstat",
"""
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
""",
libraries=[])
ffi.cdef("""
struct stat {
mode_t st_mode;
off_t st_size;
...;
};
int lstat(const char *path, struct stat *buf);
""")
if __name__ == '__main__':
ffi.compile()
When compile python example_build.py will complain that parsing error for mode_t st_mode.
cffi.api.CDefError: cannot parse "mode_t st_mode;"
:4:13: before: mode_t
A similar example given from the manual doesn't have any problems though. What am I missing? TIA.