Using C++ and ctypes together: a vast conspiracy? ;)
Lou Pecora
pecora at anvil.nrl.navy.mil
Wed Jun 3 11:19:29 EDT 2009
In article <h04s0s$7gl$6 at lust.ihug.co.nz>,
Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> wrote:
> In message <h04bjd$n93$1 at hoshi.visyn.net>, Sebastian Wiesner wrote:
>
> > <Nick Craig-Wood Mittwoch, 3. Juni 2009 00:29>
> >
> >> That said I've used C++ with ctypes loads of times, but I always wrap
> >> the exported stuff in extern "C" { } blocks.
> >
> > No wonder, you have never actually used C++ with C types. An extern "C"
> > clause tells the compiler to generate C functions (more precisely,
> > functions that conform to the C ABI conventions), so effectively you're
> > calling into C, not into C++.
>
> Seems like the only sane way to do it. In all other directions lies madness.
Agreed. I've done this several times and it works fine. Once I'm in C
I'm really in C++ and can use all my C++ code and libraries. Not a big
problem really. But maybe I'm missing something.
--
-- Lou Pecora
More information about the Python-list
mailing list