【发布时间】:2016-01-20 20:07:27
【问题描述】:
我正在尝试使用 python-cffi 来包装 C 代码。以下example_build.py 显示了尝试包装lstat() 调用:
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()
编译时python example_build.py 会报错mode_t st_mode 的解析错误。
cffi.api.CDefError: cannot parse "mode_t st_mode;"
:4:13: before: mode_t
manual 给出的类似示例没有任何问题。我错过了什么? TIA。
【问题讨论】:
标签: python python-cffi