home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7044 < prev    next >
Encoding:
Text File  |  1992-11-18  |  2.0 KB  |  46 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!sgigate!sgi!wdl1!wdl39!mab
  3. From: mab@wdl39.wdl.loral.com (Mark A Biggar)
  4. Subject: Re: cpp fails in statements like pkg'foo(DEFINE)
  5. Message-ID: <1992Nov18.180209.10301@wdl.loral.com>
  6. Sender: news@wdl.loral.com
  7. Organization: Loral Western Development Labs
  8. References: <BxvntG.61x@ibg1.ibg.sub.org>
  9. Date: Wed, 18 Nov 1992 18:02:09 GMT
  10. Lines: 34
  11.  
  12. In article <BxvntG.61x@ibg1.ibg.sub.org> ado@ibg1.ibg.sub.org (Christoph Adomeit) writes:
  13. >what is the golden way to prevent cpp from interpreting
  14. >a statement like 
  15. >#define DEFINE 99
  16. >pkg'foo(DEFINE) 
  17. >as a part of a string literal ?
  18. >In the above examples DEFINE is not replaced by "99" because
  19. >cpp thinks it's a string literal.
  20. >-- 
  21. >Origin: It's not a bug, it's a feature !
  22.  
  23. Unfortunately, a lot of CPPs out there insist on tokenizing their input as if
  24. it was a C source file.  What did you expect, it's a C preprocessor and the
  25. C standard specifically allows CPP to do this.  Of course, this means that
  26. some CPPs cannot be used to preprocess Perl scripts, but it's only a
  27. historical accident that the CPP on the machine Larry originally developed
  28. Perl on had a CPP that could be used to preprocess Perl scripts.  That feature
  29. was originally added to Perl very early to get the include file processing of
  30. PCC, the #define stuff was only incidential.  Now that 'do' and 'require' have
  31. been added to the language, the main reason for using CPP has gone away, and
  32. it could be argued that CPP support should be dropped from the Perl interpreter
  33. or a macro processor specifically designed for Perl should be created.  Note:
  34. all these problems with CPP are some of the reasons why the ch2p tool converts
  35. #define CPP lines into perl subroutines.
  36.  
  37. In answer to your question, No there is no way to tell your CPP to do things
  38. the way you want.  Either find a different (probably older) CPP that works
  39. your way or don't use CPP.
  40.  
  41. --
  42. Perl's Maternal Uncle
  43. Mark Biggar
  44. mab@wdl1.wdl.loral.com
  45.  
  46.