What's best practice to use compound literals with structs and C-APIs?
    Robert M. Münch 
    robert.muench at saphirion.com
       
    Thu May  2 07:11:37 UTC 2019
    
    
  
On 2019-05-01 19:13:54 +0000, Alex said:
>> Doesn't work because this seems to kick in some D releated run-time 
>> stuff which lead to unresolved externals during linking:
>> 
>> error LNK2001: Nicht aufgelöstes externes Symbol "...__initZ".
>> error LNK2001: Nicht aufgelöstes externes Symbol 
>> "...__xtoHashFNbNeKxSQBtQBoQBfZm".
>> error LNK2001: Nicht aufgelöstes externes Symbol 
>> "...__xopEqualsFKxSQBsQBnQBeKxQmZb".
>> 
>> Not sure, why this happens.
> 
> Found this bug: https://issues.dlang.org/show_bug.cgi?id=12374
> 
> It is closed now, because of inactivity, if you have a current case - a 
> reopen is welcome.
> However... Not sure, maybe someone else has more knowledge about this.
Thanks for the link, looks a bit related. I would need to see if I can 
create a small case which shows the problem...
> So, you generate D structs from C, right? If so, and if you need the 
> byRef at any cost - you could tweak the generator, so byRef is 
> generated for all structs.
Well, the generator is DStep... and I'm not sure if a general "byRef" 
approach would make sense. And listing affected structs manually will 
complicate the workflow again.
What I'm irriated about is, that this works:
A tmp = {x,y};
return myfunc(&tmp);
But this doesn't:
return myfunc(new A(x,y));
Or I haven't found a valid syntax to do it inline.
-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
    
    
More information about the Digitalmars-d-learn
mailing list