> * Ossama Othman said: > > > > Why? Tell me how I pass a C++ object to C, Fortran or Pascal. > > > > The same way you pass fortran to C: use wrappers, for > example. Here is > > one way of passing a static C++ method to a C function (e.g. signal > > system call) in C++ code: > > > > extern "C" void > > Base_cleanup (void *object, void *) > > { > > Base::cleanup (object, 0); > > } > > > > Simple. :-) > Perhaps, but not clean. And doesn't make sense in this > particular case... > Remember the rule of the Ockham's Razor???? I think it should > be obeyed > here... >
I think the real problem is in trying to export a language-specific construct to another language which does not support it. C does not support objects. Yes, yes. I realize that a "good C programmer can bliff and blaff, etc., to achieve an object-oriented design that will be worthy of a Nobel prize and the Pulitzer prize simultaneously, etc. etc.". However, the fact is that C is designed primarily for procedural style programming, and does not have features in place to handle C++/Java/Python/etc. objects. A better question is how a revised C++-ish library might interoperate with an object-oriented language designed to make use of polymorphism, abstraction, etc. Say, how Python might work as a front end, or how you might use Java, etc. Asking how to pass a C++ object to C is like asking how to cast a float to a byte field in assembly. Ideally, a library would (in addition to it's C++ functionality) have a C interface that doesn't really deal with the issue of objects. Say, something that would accept some standard C types and structs, and return same. -Brent