Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!snorkelwacker!ira.uka.de!smurf!nadia!ananke!kaiser From: kaiser@ananke.stgt.sub.org (Andreas Kaiser) Newsgroups: comp.lang.c Subject: Structure and Array equivalence Message-ID: <7.26F4ED23@ananke.stgt.sub.org> Date: 16 Sep 90 07:47:10 GMT Organization: Ananke, Stuttgart, FRG Lines: 40 In a message of , Dave Lee (dave@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@ananke.stgt.sub.org :: Andreas Kaiser :: Fidonet: 2:507/18.7206 (+ 2:509/5.2512) ::::::::::::::::::::