C++ and CFFI

322 views
Skip to first unread message

Daniel Papp

unread,
May 15, 2017, 6:27:15 AM5/15/17
to python-cffi
Hi!

I'm interested if one can interface C++ and python code via CFFI. I'm writing an extension and I was using Cython before but CFFI seems to be a cleaner approach.

From C++ I roughly need the STL. Is it possible to do this? Am I specific enough with this question?

Thanks,
Daniel

Tom Krauss

unread,
May 15, 2017, 8:36:50 AM5/15/17
to pytho...@googlegroups.com
+1

--
-- python-cffi: To unsubscribe from this group, send email to python-cffi+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/python-cffi?hl=en
---
You received this message because you are subscribed to the Google Groups "python-cffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-cffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ryan Gonzalez

unread,
May 15, 2017, 9:16:34 AM5/15/17
to pytho...@googlegroups.com
Technically, you can, but you need to do a ritual dance for the ABI gods and sacrifice your firstborn child.

--
Ryan (ライアン)
Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else
http://refi64.com

--

Armin Rigo

unread,
May 15, 2017, 10:42:17 AM5/15/17
to pytho...@googlegroups.com
Hi Daniel,

On 15 May 2017 at 12:27, Daniel Papp <jaka...@gmail.com> wrote:
> From C++ I roughly need the STL. Is it possible to do this? Am I specific
> enough with this question?

CFFI cannot access C++. You could play around with platform- and
compiler-specifc ABI like Ryan suggests; but, more cleanly, I would
recommend to wrap the C++ code into a C API first, and then call that
C API with CFFI. Of course you have to express the API in C, first,
not using things like the STL. This might be too annoying for your use case.


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages