static void arrays under garbage control?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 25 18:45:30 PST 2015


On Wed, Feb 25, 2015 at 08:20:37PM -0600, captaindet via Digitalmars-d-learn wrote:
[...]
> struct Stuff2Do{
>     static ubyte[1024*1024] buffer4speed = void; // even if untyped at this point
> 
>     // more
> }
[...]

Tangential note: be careful with putting a large static array inside a
struct. Structs are passed by value, which means that if you didn't
allocate that struct on the heap and you pass it around to various
functions, you will overflow your stack very quickly -- every function
call that passes the struct will consume 1MB of stack space. Many OSes
do not allocate that much space for the runtime stack.


T

-- 
Real Programmers use "cat > a.out".


More information about the Digitalmars-d-learn mailing list