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,239 of 135,536   
   John Ames to The Natural Philosopher   
   Re: naughty Python   
   02 Jan 26 08:49:25   
   
   XPost: alt.folklore.computers   
   From: commodorejohn@gmail.com   
      
   On Fri, 2 Jan 2026 10:59:55 +0000   
   The Natural Philosopher  wrote:   
      
   > > If you really needed 100 variant record in Turbo Pascal,   
   > > then you needed 100 unions in C.   
   >   
   > 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, and any means to ensure that it doesn't are   
   implementation-specific, so assumptions about casting a block of memory   
   to one struct/array or another can lead to portability issues...   
      
   ...but boy, is it handy in a pinch!   
      
   --- 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