unterminated .h files, __CAT__, etc.
der Mouse
mouse at mcgill-vision.UUCP
Tue Jul 29 08:54:11 AEST 1986
> Recently, through no fault of my own (honest, guv'nor!) I wound up
> including a header file with no terminating newline.
Fun, ain't it?
> My questions are directed more toward the handling of the missing
> newline itself:
> What do other preprocessors do in this kind of situation?
Well, in my preprocessor (yes, I rewrote cpp), a # is not special
except at the beginning of a line. Hence we have the following:
x.c contains
#include "y.c"
#include "z.c"
#include "y.c"
this is x.c contents
y.c contains, without a terminating newline
this is y.c contents
z.c contains
this is z.c contents
then cc -E (with my preprocessor) produces
# 1 "y.c"
this is y.c
# 2 "x.c"
contents#include "z.c"
# 1 "y.c"
this is y.c
# 4 "x.c"
contentsthis is x.c contents
Notice that the last token has migrated from the included file into the
including file, and that the first #include has been output literally.
> What *should* X3J11 say about these cases, if anything?
I see nothing wrong with leaving it implementation-dependent (it is an
error if the file does not end with a newline).
On another topic,
> __STR__ and __CAT__ were suggested by Tom Plum in a late-night
> working session to resolve the remaining preprocessor issues,
> The Reiser CPP is definitely out.
I don't see what's wrong with Reiser cpp's answer to the str and cat
problems (formal substitution in strings and /**/). Could someone
enlighten me? The former (formals inside ""s) can bite, but only if
you're not aware of it (using the same name for a formal and a global
within the macro can bite too, so the possibility of being bitten will
not go away with __STR__). The only thing I can see wrong with /**/
for __CAT__ is that cc -E -C, such as is used by lint, won't do
contatenation, but the preprocessor could easily be made to strip /**/
even under -C).
--
der Mouse
USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse at uw-beaver.arpa
"Come with me a few minutes, mortal, and we shall talk."
- Piers Anthony, Bearing an Hourglass
More information about the Comp.lang.c
mailing list