home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.linux.misc      Linux-specific topics not covered by oth      135,536 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 134,242 of 135,536   
   John Levine to All   
   Re: C structure portability, naughty Pyt   
   02 Jan 26 18:26:19   
   
   XPost: alt.folklore.computers   
   From: johnl@taugh.com   
      
   According to John Ames  :   
   >> No. You simply used *casting* .   
   >>   
   >> k=*(int *)(buffer +4) etc etc.   
   >   
   >You do have to be careful with this as it's not guaranteed that the   
   >compiler won't take liberties in arranging members of a struct for   
   >optimization purposes, ...   
      
   No, the C Standard says:   
      
     Within a structure object, the non-bit-field members and the units in which   
   bit-fields   
     reside have addresses that increase in the order in which they are declared.   
      
   There can be bits of padding to get fields aligned as needed, but no   
   reordering.   
   It is pretty common to use structure declarations with common fields at the   
   front to do varriant records.   
      
   --   
   Regards,   
   John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for   
   Dummies",   
   Please consider the environment before reading this e-mail. https://jl.ly   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca