Structure and Array equivalence
Andreas Kaiser
kaiser at ananke.stgt.sub.org
Sun Sep 16 17:47:10 AEST 1990
In a message of <Sep 15 00:20>, Dave Lee (dave at dptechno.uucp ) writes:
DL> struct A_STRUCT {
DL> TYPE T1,T2,T3,T4,T5 .... TN;
DL> } A ;
DL> funcA( X )
DL> A_STRUCT *X;
DL> {
DL> X->T3 = C;
DL> }
DL> funcB( X )
DL> TYPE *X;
DL> {
DL> X[2] = C ;
DL> }
DL> If you have a structure which contains members of only one type,
DL> and you have an array of the same type with the same number of elements,
DL> is the compiler guarenteed to place the members in the same offsets in
DL> both the array and structure ?
There is no guarantee that the any alignment padding is the same within
structures and arrays. There is no guarantee for any kind of alignment anyway.
DL> Q: Are funcA() and funcB() GUARENTEED to do the same thing ?
No.
Gruss, Andreas
--
:::::::::::::::::::: Internet: kaiser at ananke.stgt.sub.org
:: Andreas Kaiser :: Fidonet: 2:507/18.7206 (+ 2:509/5.2512)
::::::::::::::::::::
More information about the Comp.lang.c
mailing list