extern(C++) and struct (constness mangling problem ?)

deadalnix deadalnix at gmail.com
Tue Nov 29 07:46:55 PST 2011


Hi,

I did face a problem with extern(C++) again. Now we are talkign about 
const member method for structs. Here is a sample code to trigger the 
error :

extern(C++) {
	struct Fail {
		void method() {}
		void method() const {}
	}
}

It will generate the error Error: symbol `_ZN4Fail6methodEv' is already 
defined.

Both method are mangled the same way, regardless of constness.

On a more general basis, interfacing to C++ is damn hard to do safely ! 
If you put asside some mangling bugs, some D choices make it more 
difficult than necessary.

Notably, it's very difficult to map a C++ POD class with a default 
constructor and copy constructor/assignement overload. struct doesn't 
allow for default constructor and copy constructor isn't mappable using 
posblit. final class imply an overhead, and are references types (so 
cannot be passed by value).


More information about the Digitalmars-d mailing list