Search code examples
geventpython-cffi

Some confusion about gevent (cffi) setup


In Gevent 1.1, there are two backends, cython and cffi. What I confuse is _corecffi_build.py.

In line 331,

ffi.set_source('gevent._corecffi', _source, include_dirs=include_dirs)

I do not know why ffi.set_source does not specify sources to include related c files. And _source only contains some declarations.

How the c source files are included?


Solution

  • The "c source files" are included in a libev-specific way. In the _source string we #define LIBEV_EMBED before we #include "libev.h". Setting that macro causes libev.h itself to #include "ev.c", which is all the source libev needs.