home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13457 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  1.5 KB

  1. Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
  2. From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Print #define
  5. Message-ID: <1992Sep10.143618.3126@crd.ge.com>
  6. Date: 10 Sep 92 14:36:18 GMT
  7. References: <1992Aug26.124652.9509@alw.nih.gov> <DeqcqB1w165w@bluemoon.rn.com> <1992Sep9.152715.8286@us-es.sel.de> <1992Sep9.172812.4462@organpipe.uug.arizona.edu>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 30
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. In article <1992Sep9.172812.4462@organpipe.uug.arizona.edu>, dave@cs.arizona.edu (Dave Schaumann) writes:
  15. |> In article <1992Sep9.152715.8286@us-es.sel.de>, lisa@us-es (Lisa Goulet) writes:
  16. |> >In K&R C, is there a way to print a preprocessor variable?
  17. |> >e.g.  With the following define 
  18. |> >
  19. |> >        #define Architecture hp300
  20. |> >
  21. |> >      to be able to print the "hp300" part.
  22. |> 
  23. |> If you mean string-izing tokens ala ANSI C's `#' operator, ther is no
  24. |> portable way to do it.  You could try this:
  25. |> 
  26. |> #define stringize( x ) "x"
  27.  
  28. This does not have the desired effect on any of the old-style compilers
  29. I'm aware of. The result of `stringize(Architecture)' would be
  30. `"Architecture"', not `"hp300"'.
  31.  
  32. |> 
  33. |> Many K&R preprocessors used this as an "undocumented feature" to stringize
  34. |> tokens.
  35. |> 
  36. |> -- 
  37. |> Dave Schaumann            dave@cs.arizona.edu
  38.  
  39. -- 
  40. ==================
  41. Chris Volpe
  42. G.E. Corporate R&D
  43. volpecr@crd.ge.com
  44.