Original Post
What would a macro (in C/C++) like this do and what would it be used for?
#define test(z, w) (int)(&(((z *)0)->w))
This is what I think so far:
This takes 2 parameters, z being an instance of some class/struct (lets say foo), w being a member of foo.
1. If z is intended to be a type name of struct foo, the (z*)0 -> w would become (foo *)0 -> w allowing the type checker to access the w field in foo.
2. The data member''s address or it''s struct''s pointer address is set to 0 (maybe?)
3. The address of the data member ''w'' is then converted to an int
Can someone tell me exactly how this works and maybe what it''s purpose is? I have a feeling it is either pushing the data member''s address to the top of the stack or creating a null pointer out of it...I am not sure.
