c-std-porting.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Armin Rigo <armin.rigo@gmail.com>
To: python-cffi@googlegroups.com
Cc: c-std-porting@lists.linux.dev
Subject: Re: [python-cffi] cffi.FFI.cdef and implicit function declarations
Date: Wed, 8 Feb 2023 13:12:43 +0100	[thread overview]
Message-ID: <CAMSv6X0-VSeov_EwdVEg2n2HawDspnC9P+b1S-WZW-nRinEaGA@mail.gmail.com> (raw)
In-Reply-To: <87a61oqxgi.fsf@oldenburg.str.redhat.com>

Hi Florian,

On Wed, 8 Feb 2023 at 11:10, Florian Weimer <fweimer@redhat.com> wrote:
> For example, this snippet:
>
> “
> import cffi
>
> ffi = 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 = 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ôt,
Armin Rigo

  reply	other threads:[~2023-02-08 12:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 10:10 cffi.FFI.cdef and implicit function declarations Florian Weimer
2023-02-08 12:12 ` Armin Rigo [this message]
2023-02-08 12:18   ` [python-cffi] " Armin Rigo
2023-02-08 13:57     ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMSv6X0-VSeov_EwdVEg2n2HawDspnC9P+b1S-WZW-nRinEaGA@mail.gmail.com \
    --to=armin.rigo@gmail.com \
    --cc=c-std-porting@lists.linux.dev \
    --cc=python-cffi@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).