Preprocessor question

Ray Berry ray at ole.UUCP
Thu Jan 19 08:32:44 AEST 1989


   Here's an easy question regarding preprocessor string-izing and subsequent
  rescanning...

#define VAL 3
#define STR(x) #x
   .
   .
  puts("val is " STR(VAL));
- - - - - - - -
   Turbo C produces "3" for STR(VAL); Microsoft produces "VAL" and 
leaves it at that.  
   Which behavior is correct?  Further, if Microsoft's is correct, how can
one parenthesize a #define'd value to turn it into a character string?

-- 
Ray Berry  KB7HT uucp: ...{uw-beaver|uiucuxc}tikal!ole!ray CS: 73407,3152 
Seattle Silicon Corp. 3075 112th Ave NE. Bellevue WA 98004 (206) 828 4422



More information about the Comp.lang.c mailing list