Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!topaz!husc6!harvard!cmcl2!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: net.lang.c Subject: unterminated .h files, __CAT__, etc. Message-ID: <470@mcgill-vision.UUCP> Date: Mon, 28-Jul-86 18:54:11 EDT Article-I.D.: mcgill-v.470 Posted: Mon Jul 28 18:54:11 1986 Date-Received: Wed, 30-Jul-86 01:43:20 EDT References: <5722@think.COM> <2244@brl-smoke.ARPA> Organization: McGill University, Montreal Lines: 64 > 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@uw-beaver.arpa "Come with me a few minutes, mortal, and we shall talk." - Piers Anthony, Bearing an Hourglass