Re: Creating fixed array on stack

2019-01-12 Thread Seb via Digitalmars-d-learn
On Saturday, 12 January 2019 at 13:17:00 UTC, Adam D. Ruppe wrote: On Saturday, 12 January 2019 at 08:10:47 UTC, Andrey wrote: But this requires using of C function "alloca". I think this cause some RT overhead (and in output asm code) in comparison with C++ variant. Or I'm not right? alloca

Re: Creating fixed array on stack

2019-01-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 January 2019 at 08:10:47 UTC, Andrey wrote: But this requires using of C function "alloca". I think this cause some RT overhead (and in output asm code) in comparison with C++ variant. Or I'm not right? alloca is a magical function; a compiler intrinsic that works the same

Re: Creating fixed array on stack

2019-01-12 Thread Andrey via Digitalmars-d-learn
On Friday, 11 January 2019 at 15:23:08 UTC, Dgame wrote: On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote: Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; In D the "count" is part of type and must be known at CT but in example it is RT.

Re: Creating fixed array on stack

2019-01-11 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 11 January 2019 at 15:23:08 UTC, Dgame wrote: On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote: Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; Small correction: this is valid in C, but not in C++. In D the "count" is part of

Re: Creating fixed array on stack

2019-01-11 Thread Dgame via Digitalmars-d-learn
On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote: Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; In D the "count" is part of type and must be known at CT but in example it is RT. How to do such thing in D? Without using of heap. You

Creating fixed array on stack

2019-01-11 Thread Andrey via Digitalmars-d-learn
Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; In D the "count" is part of type and must be known at CT but in example it is RT. How to do such thing in D? Without using of heap.