On 3 September 2012 18:15, Andrej Mitrovic <[email protected]> wrote: > On 9/3/12, Iain Buclaw <[email protected]> wrote: >> Indeed, C++ classes are always passed in memory by design. Whereas > pointers could be passed in registers. > > That's cool. I learn something new every day. :) > >> And this is one >> reason why you need to ensure that function signatures match in both D >> and C/C++ code. > > Yeah that's doable when the type is a POD but when it's a class > returned by value there is no equivalent in D since D classes are > always references, so I can't match the D function signature to the C > one. > >> extern "C" >> FileName value_FileName(void* refVal) >> { >> return *(FileName*)refVal; >> } > > That won't work either since FileName is still in the return type and > I can't match the function signature on the D side (it still crashes). > The only thing I can think of is to match the C++ function signature > to the D side via something like: >
Ah, sorry, my bad. I was testing marking D structs as addressable (meaning are always passed in memory) whilst in the middle of looking at the difference between D and C++ codegen. Must have left that turned on still in my copy of gdc. ;-) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
