Cpp/D interface semantic

Guillaume Chatelet via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 26 00:51:16 PDT 2016


This is currently part of the dmd test suite [1]:

> extern (C++) interface E
> {
>     int bar(int i, int j, int k);
> }
> 
> extern (C++) int callE(E);
> 
> static assert (callE.mangleof == "_Z5callEP1E");

The last line checks that callE() will pass its argument by 
pointer.

This is fine in the case where E is a D interface because of 
reference semantics: it should be passed by pointer.

But, in the case where an extern(C++) function calls an 
extern(C++) type should it be value semantic - as it is in C++ - 
or reference semantic - as it is in D?

Thoughts?

--
1. 
https://github.com/dlang/dmd/blob/master/test/compilable/cppmangle.d#L102


More information about the Digitalmars-d mailing list