Redefining keywords (is #define short int legal?)

Geoff Kuenning geoff at desint.UUCP
Tue Jan 22 17:27:25 AEST 1985


Having the good fortune [:-)] to port a program to a DG C compiler, I carefully
ran it through lint first.  Among other things, I added a whole bunch of
stuff like the following to keep lint happy:

    (void) strcpy (buf, pathname);

When I got it to the DG, I was pleased to discover it understood the void
type.  I was less pleased to learn that it refused to accept the above
construct.  No problem, though, right?  You just do the old reliable

    #define void int

and all becomes well.  Only, the DG C compiler disagrees.  It gave me an
error message on the above line.  Seems that the preprocessor is integrated,
and refuses to allow you to redefine keywords.  It wasn't hard to work around
(just replace all void's with VOID's, and #define VOID void on intelligent
compilers), but it brings up a question.  Is it legal (by the ANSI standard)
to treat C keywords specially *in the 'preprocessor'*?  (I quote
'preprocessor' because I don't think the standard actually requires it to be
a separate pass.)
-- 

	Geoff Kuenning
	...!ihnp4!trwrb!desint!geoff



More information about the Comp.lang.c mailing list