Re: [python-cffi] cffi.FFI.cdef and implicit function declarations
Armin Rigo <[email protected]> Wed, 8 Feb 2023 13:12:43 +0100
| Newsgroups | dev.linux.lists.c-std-porting |
|---|---|
| Message-ID | <CAMSv6X0-VSeov_EwdVEg2n2HawDspnC9P+b1S-WZW-nRinEaGA@mail.gmail.com> |
Hi Florian, On Wed, 8 Feb 2023 at 11:10, Florian Weimer <[email protected]> wrote: > For example, this snippet: > > =E2=80=9C > import cffi > > ffi =3D cffi.FFI() > ffi.cdef("int puts(const char *);") > ffi.cdef("const char *getenv(const char *);") > ffi.cdef("const char *gnu_get_libc_release(void);") > lib =3D ffi.verify() > lib.puts(lib.getenv(b"TERM")) > lib.puts(lib.gnu_get_libc_release()) Yes, it's expected not to work. First, the ffi.verify() should not be used any more and has been deprecated for many, many years. But if you want to use it anyway, then: ffi.verify() must be called with an argument which is the extra piece of C source code, and that *must* make the declared functions available to the C code. A typical usage is to say ffi.verify('#include <something.h>'). If you are getting an "implicit function" warning from the C compiler, then this was not done correctly. A bient=C3=B4t, Armin Rigo