This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Casting a pointer to a structure


Marius Vollmer <mvo@zagadka.ping.de> writes:

>     struct env_funcs **ptr1 = ...;
>     struct m *ptr2 = (struct m *)ptr1;
> 
> Is this safe too?  How can this be safely generalized to
> non-zero-offset members?

Yes it is.  ANSI guarantees that a pointer to a structure
can be casted to a pointer to its first element and vice versa.

And I think this first element can also be a complex type (a structure
or union) but I am not sure.


Jost
-- 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]