Another sizeof question

Michael Meissner meissner at osf.org
Wed Oct 31 04:15:25 AEST 1990


In article <492 at taumet.com> steve at taumet.com (Stephen Clamage) writes:

| Some C compilers support sizeof in the preprocessor.  The results are
| then kind of weird.  Such preprocessors sometimes recognize the size of
| the built-in types (int, long, etc), but not user types.  Recognizing
| the size of user types is part of the C compilation process, not just
| preprocessing, so a stand-alone preprocessor must either act as a
| complete C parser, or act differently than when it is part of the
| complete compilation.

When I worked at Data General on the MV C compiler, I added sizeof
support to the preprocessor (which is called as a coroutine from
within the lexer).  Because the preprocessor was built into the
compiler, it involved no hand wringing.  In fact, it would have been
more work to disable sizeof, since the same parser was used to parse
#if/#elif expressions as the normal expressions.

This turned out to be useful in non-portable system codes to make sure
a structure was the precise size needed by the external specification.
Many of the internal DG types complained when the GNU and Greenhills
compilers on the 88k did not support this feature....


--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.std.c mailing list