[lug] An unusual C construct

Kenneth D Weinert kenw at quarter-flash.com
Wed Jul 28 22:57:09 MDT 2010


sizeof(((tCLAIM_tbl_def *)0x0)->acHealth_Service_Id)

tCLAIM_tbl_def is a structure typedef.

I understand the intent of this code - it's to get the size of the
field in the tCLAIM_tbl_def structure so the equivalent field in the
current structure (not shown) can be the same size.

It's just that in all my years of coding C I've never seen this
technique used. It does work, at least on the AIX compiler we're using
here.

I'll also note that it's hard to google - at least I've not come up
with the correct search terms to find an explanation.

It's nothing I need to change - I'd just like to understand how it works :)

They also have the habit of passing in a pointer and using it like:

ptr[0].field

where normal people would have used

ptr->field



-- 
Ken Weinert

I'm once again gainfully employed. Thank you all for your thoughts and 
prayers.



More information about the LUG mailing list