ctypes/C++ segfault accessing member variables
问题 I am no stranger to the python ctypes module, but this is my first attempt at combining C++, C and Python all in one code. My problem seems to be very similar to Seg fault when using ctypes with Python and C++, however I could not seem to solve the problem in the same way. I have a simple C++ file called Header.cpp : #include <iostream> class Foo{ public: int nbits; Foo(int nb){nbits = nb;} void bar(){ std::cout << nbits << std::endl; } }; extern "C" { Foo *Foo_new(int nbits){ return new Foo