[net.lang.c] Holes in Structures

alan@allegra.UUCP (09/10/83)

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.

I have many gripes with C.  Still, I will take C as it is, any day of
the week, if the alternative is to have every hacker add his favorite
half-baked idea to the compiler.

If you don't like a system, you can (a) work to modify it, or (b) work
to replace it with a better system.  Anarchy is no solution.  Pascal is
a total mess because so many compiler writers have taken liberties with
the definition of the language.  Is this what you want to see happen to
C?


	Alan Driscoll
	Bell Labs, Murray Hill

dhb@rayssd.UUCP (Brierley) (09/12/83)

I have a major problem with changing the way the compiler handles
structures.  I am currently working on what will become a heavily
used major program package that has at its heart a series of data
structures.  No problem so far, huh?  Well, the main thing that I
do with these structures is to ship them across a local area net
to another machine.  No problem if all machines run EXACTLY the
same compiler.  However, there are several 4.1BSD VAX machines,
a V7 pdp, and several VMS VAX machines.  I have already run into
problems with the VMS machines in that the DEC C compiler knows
that integers do not have to be aligned on a longword boundary on
the VAX and therefore do NOT have to be aligned by leaving holes
in the structure.  Now unless someone wants to convince DEC that
they should make their compiler more compatible by making it less
efficient,  I suggest we leave everything the way it is.

--
	Dave Brierley
	Raytheon Co.; Portsmouth RI; (401)-847-8000 x4073
	...!decvax!brunix!rayssd!dhb
	...!allegra!rayssd!dhb
	...!linus!rayssd!dhb

suitti@CSvax:Pucc-H:pur-phy.UUCP (09/12/83)

alan@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