Should such type conversions be safe?
Alan Curry
pacman@TheWorld.com
Mon, 8 Apr 2002 13:12:11 -0400 (EDT)
Alan DeKok writes the following:
>
>"chen jin" <celadonbird@hotmail.com> wrote:
>> the coding coverts forcibly CONF_ITEM pointer to CONF_ITEM_SECTION pointer,
>> but the two structs are of different structure,How can they be safely
>> converted?
>
> In general, they can't. C allows compilers to re-arrange the
>elements of a data structure, so the structures can't be cast.
pad, yes. rearrange, no.
It is allowed to cast a pointer to a struct to a pointer to its first
element, which is what I did with the CONF_ subclasses.