This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hello
I would like to know if I can assume that a structure and its first member will always have the same address. For instance, with the following code:
/* ----------------------------------*/
struct foo { any_type first_member; };
struct foo my_struct;
void * addr1 = &my_struct; void * addr2 = &my_struct.first_member;
/* ----------------------------------*/
can I be sure that `addr1' will be equal to `addr2' ?
thanks
I think so. IF yours is a simple struct, ie. no hereditaritey or any C++ thing.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |