V
vijay
hi,
if you see assembly then sizeof operator has sizeof(type) or
sizeof(variable) at compile time. How does C compiler gets value at
compiler time.?
How can we implement sizeof operator?
the implementation as macro is as below
#define sizeof_op1(val) (&val +1 ) - &val // for variable ex
sizeof_op1(n)
#define sizeof_op2(type) ((type*) (10) + 1) - (type*) (10) // for type
as sizeof_op2(int)
is there any other way to implemnent sizeof operator in C ? can we
implemnt sizeof_op2 as function. is there any way to combine above two
macros in one macro or function.
Thanks
vijay
if you see assembly then sizeof operator has sizeof(type) or
sizeof(variable) at compile time. How does C compiler gets value at
compiler time.?
How can we implement sizeof operator?
the implementation as macro is as below
#define sizeof_op1(val) (&val +1 ) - &val // for variable ex
sizeof_op1(n)
#define sizeof_op2(type) ((type*) (10) + 1) - (type*) (10) // for type
as sizeof_op2(int)
is there any other way to implemnent sizeof operator in C ? can we
implemnt sizeof_op2 as function. is there any way to combine above two
macros in one macro or function.
Thanks
vijay