phil@ux1.cso.uiuc.edu (02/02/90)
Another problem you can encounter when dealing with data structure formats imposed by hardware, particularly external hardware, is the byte order. An example is handling TCP and IP headers. The exact data structure is defined very specifically, but making code that can deal with it AND be portable across big and little endian machines requires a lot of care. Such portable code may not be the most optimal depending on how it is done. --Phil Howard, KA9WGN-- <phil@ux1.cso.uiuc.edu>
carroll@m.cs.uiuc.edu (02/24/90)
>/* Written 11:34 am Jan 29, 1990 by henry@utzoo.uucp in m.cs.uiuc.edu:comp.lang.c */ >In article <51385@bbn.COM> jgrace@BBN.COM (Joe Grace) writes: >>... I think the language, C (and C++), is to blame (and >>would prefer C and C++ to pack struct members as suggested by >>the programmer's struct definition). > >The basic problem here is that the compiler cannot read minds, and the >language does not provide a way to tell the compiler which of two >interpretations is wanted. >-- >1972: Saturn V #15 flight-ready| Henry Spencer at U of Toronto Zoology >1990: birds nesting in engines | uunet!attcan!utzoo!henry henry@zoo.toronto.edu >/* End of text from m.cs.uiuc.edu:comp.lang.c */ Wouldn't this be a place for a #pragma extension? I.e., the default behaviour is to layout the structure in textual order as is done now, while a #pragma PACK_STRUCTURES would tell the compiler that the program doesn't depend on the ordering of the structure members, and the compiler is free to rearrange them in order to produce the minimum memory size based on alignment restrictions. This way compilers without the pragma would still run the code, but pay the memory cost. Alan M. Carroll "Like the north wind whistling down the sky, carroll@cs.uiuc.edu I've got a song, I've got a song. Conversation Builder: I carry it with me and I sing it loud + Tomorrow's Tools Today + If it gets me nowhere, I'll go there proud" Epoch Development Team CS Grad / U of Ill @ Urbana ...{ucbvax,pur-ee,convex}!cs.uiuc.edu!carroll