JK> Now my question is, does the compiler treat
JK> "sizeof(StructName);" as a constant? During compile time
JK> will it look up the size of the stuct and simply use that
JK> number instead of calculating the size of the stucture
JK> each time?
KK> Why don't you write a little program to test the time it
KK> takes to find sizeof(int) and compare the results to
KK> finding sizeof(MyStruct)?
KK> It should add sizeof(MyStruct) to a table of values and the
KK> lookup time should be equal if it does not calculate it on
KK> every call.
KK> My tests seem to indicate that they take the same ammount
KK> of time.
In this case, you'd want to check the assembly code produced. In there,
you'd find that sizeof() was being replaced by a constant.
--- Maximus/2 3.01
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|