dollar signs in identifiers (was: warning: '/*' within comment)

Walter Murray walter at hpcllca.HP.COM
Sat Jun 9 08:29:35 AEST 1990


Karl Heuer writes:

> (The Standard requires that the strictly conforming program
> 	#include <stdio.h>
> 	#define foo$bar /* define foo to be dollar-bar */
> 	#ifdef foo
> 	int main(void) { printf("yes\n"); return 0; }
> 	#else
> 	int main(void) { printf("no\n"); return 0; }
> 	#endif
> must print "yes"; normal VMS behavior would be to treat `foo$bar' as a single
> token and print "no".)

I don't see how this can be a strictly conforming program.  The source
character set is implementation-defined (page 11, lines 3-4), and there
is nothing in the standard that requires $ to be a member.  (See also
page 11, lines 29-32.)

In fact, I would have trouble convincing myself that either of the 
following is a strictly conforming program:

   /* Program 1 */ int main () { /* $ */ }
   /* Program 2 */ int main () { '$'; }

Any thoughts?

Looking at this from a different perspective, must a conforming
implementation on an 8-bit-byte machine be prepared to accept all
256 possible bytes in a string literal?  Must it map them to 256
distinct values?  I think not.  The mapping of source file characters
to the source character set in translation phase 1 is not defined
by the standard.

Walter Murray
-------------

 



More information about the Comp.std.c mailing list