Is the following portable and safe?
Given n different structure declarations, where each structure begins
with the same member type, can any instance of any of the structures
be cast to the (pointer) type of the first member?
e.g.
struct foo {
const char *s;
...
};
struct bar {
const char *s;
...
};
int gefahr(struct foo *Foo, struct bar *Bar) {
return strcmp((const char *s)Foo, (const char *s)Bar);
}
Likewise if the first member were a more complex data type, but
nevertheless the same between the different structures.
It seems safe to me, but I can't explain why :-)
Cheers,
--
Jacques Vidrine / [EMAIL PROTECTED] / [EMAIL PROTECTED] / [EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message