Holes in Structures

suitti at CSvax suitti at CSvax
Tue Sep 13 01:31:02 AEST 1983


alan at allegra says:
Stephen Uitti suggests hacking the C compiler to sort fields within a
structure so that there are no holes.  Then structure comparison (yes,
another hack to the compiler) would work correctly.

my reply:
	This discussion started with structure comparisons.  I'm more
interested in data space savings.  I work with a pdp-11/44.  It has
split instruction & data.  With autmomatic overlays, text space is not
usually a problem.  64k data space is ALWAYS a problem.  Saving a little
space in s structure won't anything, unless it happens to be an array
of structures.  In this case, a pessimistic order (specified by the
programmer) could be significant.  I suppose the programmer could "know",
and just re-arrange.
	C does very little optimizing.  The philosophy is "let the programmer
do that".  C allows one to write code that can compile efficiently, but
does not enforce efficiency.
	This philosophy is good for writting a kernel.  But I often get
code written on VAXen, etc, optimized (if at all) for differant machines.
Sometimes, the mechanism I want is not available (efficient float handling,
array handling).
	I'm not one to use the "newest" features.  These should be tried &
evaluated at length before distribution.  An example of this is "enums".
They are so un-powerful as to be useless.  Most people I know use #define's
instead.  But, I would start using floats (instead of doubles) if they
could be made twice as fast (instead of slower) (as they should be).

Stephen Uitti (physics site manager)
...pur-ee!Physics:suitti
...purdue!Physics:suitti



More information about the Comp.lang.c mailing list