sizeof a struc field

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Sat Oct 28 02:46:40 AEST 1989


In article <1003 at cirrusl.UUCP>, dhesi at sunseeker.UUCP (Rahul Dhesi) writes:

|          sizeof ((type *)x)->member

  If x is not a pointer type I'm sure you mean 
	sizeof ((type *)&x)->member
			^

  This is the portable way to do it, but some compilers will complain
mightily about casting the address of a non-struct to a struct. The most
portable way would be to have a dummy variable of the pointer to struct
type (or use one if you anready have it).
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list