Jump to content
  • Advertisement
Sign in to follow this  

Boost.Python pointer parameters

This topic is 4500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1. If I want to expose a C++ function like: void f(string* ptr) or void g(int* ptr), do I have to explicitly expose string and int to python? Trying to call f() or g() from Python w/ a string or int respectively gives me a "does not match C++ signature" error. 2. If I have:
void acceptPtr(C* ptr)
	delete ptr;
	ptr = NULL;
and I call acceptPtr() from Python:
c = module.C()
How is c passed? I defined the deconstructor of C to print out a message, which it did following the call to acceptPtr(), which should mean that ptr was successfully deleted. However, after the call to acceptPtr(), the c object in Python was still working like it wasn't deleted (I could still access member variables and call member methods with it). Does Python pass a new'd copy of the Python object? EDIT: In regards to #2, it seems that the member variable values for c got erased so I'm thinking that the c object in Python was actually deleted by the acceptPtr() function in C++, and for some reason just bits and pieces of it are still floating around in memory. I'm also guessing this means Python objects are passed in to C++ functions as a new'd object?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!