see sizeof() operator -- but the size of a pointer is always the same on 32-bit compilers.
Hm.. Mr. Dragon, i think you are confusing it with something else. The OP wants the size of the "activation record" and not the variable.
For eg. when the program control enters the function, the whole function is pushed in stack by allocating it a stack frame, and the OP wants to know how to find the amount of space consumed by that procedure in the stack.
I dont know why you want to find the "size" of activation record, coz that thing is pretty much transparent even to a C programmer and not brought into consideration unless you go in the Assembly lang or Operating system theory depths.
But just for some knowledge, see HERE
If that's what he wants, then its pretty small and depends on the processor and sometimes the compiler. Here is an example of how the compiler generates the startup code for a function on intel processors. Other processors will be different.
sub sp,<size of local variables>
the stack frame size is not fixed -- it depends on the parameters passed to the function, and whether the parameters are pushed onto the stack or passed in registers. Read the link -- it gives a much better explaination. What you are attempting to do in your original question just simply is not possible.
AFAIK, the AR of a procedure always starts with the return value. That's considering the stack fills from bottom to top, the return value would always be at the bottom. The size of the return value is fixed, since it's an address.
How about surtracting the return value of the procedure and the return value of the next procedure (which would be above the 1st one in the stack). Will that work ?
> I'm trying to achieve just what a said: find the size of a procedure's AR
These are good answers.
a) because the code is destined for an embedded system with very limited stack space, and I need to monitor how much stack space each function requires.
b) I'm writing some inter-language porting code, so I need to know how to arrange the stack to make proper function calls.
This is a bad answer
c) I'm writing some malware and I want to skip up the stack a couple of frames and overwrite the return address to get into my malware so I can do all sorts of nasty stuff.
> but the C code should be independant of the os/compiler
I'll say it again, since you seem to be hard of hearing.
There is NO portable way for you to find this out.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...