Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-05-01 14:47, Robert M. Münch wrote: I use some C library that uses structs and many functions that use pointer to structs as arguments: struct A {...}; myfunc(A *myA); In C you can do this to get a lvalue: myfunc(&(A){...}); In D this doesn't work and I get an "is not an lvalue and c

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-02 Thread Alex via Digitalmars-d-learn
On Thursday, 2 May 2019 at 07:11:37 UTC, Robert M. Münch wrote: On 2019-05-01 19:13:54 +, 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".

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-02 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-05-01 19:13:54 +, 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 "...__xtoHashFN

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Alex via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 14:59:48 UTC, Robert M. Münch wrote: On 2019-05-01 14:23:37 +, Alex said: However, to rebuild the same structure, auto ref parameters may be appropriate. https://dlang.org/spec/template.html#auto-ref-parameters That would need me to change myfunc which is not

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-05-01 14:23:37 +, Alex said: On Wednesday, 1 May 2019 at 12:47:22 UTC, Robert M. Münch wrote: I use some C library that uses structs and many functions that use pointer to structs as arguments: struct A {...}; myfunc(A *myA); In C you can do this to get a lvalue: myfunc(&(A){...

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Alex via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 12:47:22 UTC, Robert M. Münch wrote: I use some C library that uses structs and many functions that use pointer to structs as arguments: struct A {...}; myfunc(A *myA); In C you can do this to get a lvalue: myfunc(&(A){...}); In D this doesn't work and I get an "i

What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Robert M. Münch via Digitalmars-d-learn
I use some C library that uses structs and many functions that use pointer to structs as arguments: struct A {...}; myfunc(A *myA); In C you can do this to get a lvalue: myfunc(&(A){...}); In D this doesn't work and I get an "is not an lvalue and cannot be modified". What's the correct D-ish