3 ms·
You can't pass a C++ object with a user-defined copy constructor or a non-trivial default to a C function. If you want to pass an object from C++ to C it has to
by zabzonk 6y ago
You can't pass a C++ object with a user-defined copy constructor or a non-trivial default to a C function. If you want to pass an object from C++ to C it has to be POD (plain old data) i.e. effectively a C struct.
- haneefmubarak 6y agoSure, but I was thinking more of how C++ calling conventions typically tend to follow C calling conventions on a given architecture, so AIUI you'd either have to have a differentish calling convention or inefficiently require callees to make copies of already copied objects. Not that there's anything intrinsically wrong with having a differentish calling convention for C and C++ - it'd just add a smidgen more complexity is all.