Re: errata/364: Preprocessor macros within strings.

From: Stephen Williams (steve@icarus.com)
Date: Sun Jun 15 2003 - 17:40:07 PDT

  • Next message: Shalom Bresticker: "errata for 1364-2001c"

    Precedence: bulk

    The following reply was made to PR errata/364; it has been noted by GNATS.

    From: Stephen Williams <steve@icarus.com>
    To: Cc: etf-bugs@boyd.com
    Subject: Re: errata/364: Preprocessor macros within strings.
    Date: Sun, 15 Jun 2003 17:30:42 -0700

        module main;
        `define HI Hello
        initial $display("`HI, world.");
        endmodule
     
     Actually, here I am following up to my own errata report. It appears
     that at least one compiler in the wild (besides Icarus Verilog) does
     indeed do macro substitution within strings.
     
        <http://www.icarus.com/cgi-bin/ivl-bugs?findid=622>
     
     This suggests that I'm not losing it completely, and perhaps macro
     substitution within strings is legal. That's tricky business. To wit:
     
        `define foo "Hello"
        initial $display("`foo makes a mess");
     
     One might simply call this a You-get-what-you-deserve type of coding
     error, given my original observation that it is not explicitly
     prohibited, and in this case macro expansion within strings should
     be explicitly allowed within strings.
     
         NOTE: Macros are substituted within lexical strings. A macro
         value that contains double-quote characters may therefore cause
         an error if it is itself (or if it contains) a quoted string,
         as the double-quotes within the macro would interfere with the
         lexical string itself.
     
     Personally, I prefer not allowing macro substitution within strings.
     
     --
     Steve Williams "The woods are lovely, dark and deep.
     steve at icarus.com But I have promises to keep,
     http://www.icarus.com and lines to code before I sleep,
     http://www.picturel.com And lines to code before I sleep."
     
     



    This archive was generated by hypermail 2.1.4 : Sun Jun 15 2003 - 17:40:51 PDT and
    sponsored by Boyd Technology, Inc.