Basically I want what alloca does, but instead of considering the constructor's scope, I want it to hand to the constructor call's enclosing scope.
On Mon, May 7, 2012 at 5:29 PM, Alex Rønne Petersen <xtzgzo...@gmail.com> wrote: > On 07-05-2012 14:37, Gor Gyolchanyan wrote: >> >> I can't use alloca, because the stack-based allocation will be done in >> the constructor and alloca will free the memory as soon as the >> constructor exists. >> >> On Mon, May 7, 2012 at 4:01 PM, Alex Rønne Petersen<xtzgzo...@gmail.com> >> wrote: >>> >>> On 07-05-2012 13:58, Gor Gyolchanyan wrote: >>> >>>> >>>> I'm working on dynamic memory layout manager. Simply put, it will >>>> allow one to create and use struct types at run-time. >>>> Normally, you create a struct at compile-time type by specifying an >>>> ordered list of fields, each with its own type (basically a size) and >>>> name. >>>> You then access those fields by calling a compile-time evaluated dot >>>> operator, which computes the address of the specified field given the >>>> address of the struct. >>>> What I'm trying to make is precisely that, except at run-time. >>>> >>>> My question is: what is the best way of allocating such a structure on >>>> the stack? It will, of course, have a dynamically known size. >>>> >>> >>> alloca? >>> >>> -- >>> - Alex >> >> >> >> > > If that's the case, I don't know how you actually want this stack allocation > to work. The only way I see that you could do it would be with dirty hacks > making assumptions about the compiler, platform, calling convention, ... > > -- > - Alex -- Bye, Gor Gyolchanyan.