Because it doesn't work very well. In particular, the C preprocessor doesn't know Perl syntax. Take this tiny example and save it into cpp.pl:

#define FOO "bar" print qq(The value of FOO is "), FOO, qq("\n);
and then try it out:
$ perl cpp.pl The value of FOO is "FOO" $ perl -P cpp.pl The value of "bar" is "FOO" $
It expands it when it shouldn't and doesn't when it should.

I expect that you could get many C preprocessors to choke or issue warnings on fairly common Perl syntax as well.

This is enough of a reason for me to not use such a trick. There are several other good reasons to not use this given in the thread. One of which I ran into just trying to demonstrate how my tiny example fails. First, on Win32 even with MS VC++ installed:

> perl -P cpp.pl 'cl' is not recognized as an internal or external command, operable program or batch file. > vcvars32 Setting environment for using Microsoft Visual C++ tools. > perl -P cpp.pl Command line error D2003 : missing source filename >
Random Unix box:
$ perl -P cpp.pl ngcc: -: No such file or directory ngcc: No input files specified. $

                - tye

In reply to Re: C pre-processor in Perl (breaks) by tye
in thread C pre-processor in Perl by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.