C style array declaration.

rikki cattermole rikki at cattermole.co.nz
Mon Mar 26 10:28:35 UTC 2018


On 26/03/2018 11:16 PM, Aedt wrote:
> I'm a big fan of betterC. In C, you can initialize an array without 
> specifying the length like this
> int ia[ ] = {0, 2, 1};
> 
> What is the translation of this? Note that int[] is a different type 
> than C's arrays. 
> https://dlang.org/spec/interfaceToC.html#data_type_compat says there are 
> no equivalent to this. What's the workaround?
> 
> Also, is it possible to retrieve the pointer of the sequence of actual 
> data from std.container.array? If all fails I'd like to use this container.

Scroll further down.

C: T[] -> D: T*

https://dlang.org/spec/interfaceToC.html#passing_d_array


More information about the Digitalmars-d-learn mailing list