C-like static array size inference - how?

arandomonlooker shdkahdkhhhhhii at gmail.com
Tue Jun 7 00:04:31 UTC 2022


Hello.
I am working on a project related to low-level development as a 
beginner, and i decided to pick D as the most optimal programming 
language for that, in large part because of it's strong 
integration with C and C++.
I happen to have a lot of arrays that i want to translate to D, 
formulated as follows (it's a unrelated example):

```c
int numbersINeed[] = {1, 2, 3, 4, 5};
```

I usually transcribe them as follows, because the previous syntax 
causes a compiler error:

```d
int numbersINeed[] = [1, 2, 3, 4, 5];
```

As i'm using the betterC mode, it's complaining about TypeInfo 
being absent. Can't i use some feature to imply that D must 
deduct the size from the array i am assigning, like an 
underscore? Can't D do that?
Thanks in advance to you all.


More information about the Digitalmars-d-learn mailing list