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