Topic: preprocessor example


Author: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Date: 1997/03/05
Raw View
Alexander Krotoff <krotoff@such.srcc.msu.su> writes:

|>  This is about 2nd CD section 16.3.5 [cpp.scope] pagraph 6.
|>
|>  In the exaple symbol `@' is used. As far as I see
|>  this symbol do not form any preprocessing token and
|>  even cannot be used in the preprocessing token.
|>
|>  Is this example incorrect ?

Not at all.  "@" is a valid preprocessing token; under 2.4, one of the
valid forms of a preprocessing token is: "each non-white-space character
that cannot be one of the above".  "@" qualifies under this rule.

Of course, if the '@' gets through the preprocessing, there will be no
way to convert it into a valid token.  However, it can still be legally
used in the preprocessor, either as (part of) an argument to # (as in
the example), or in building a file name, e.g.:

    #define FUNNY_FILE_NAME < ## @ ## .h ## >
    #include FUNNY_FILE_NAME

--
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
     -- Conseils en informatique industrielle --
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Alexander Krotoff <krotoff@such.srcc.msu.su>
Date: 1997/03/03
Raw View
This is about 2nd CD section 16.3.5 [cpp.scope] pagraph 6.

In the exaple symbol `@' is used. As far as I see
this symbol do not form any preprocessing token and
even cannot be used in the preprocessing token.

Is this example incorrect ?

Thank you in advance,
Alexander.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: Gerard Weatherby <gerardw@alum.mit.edu>
Date: 1997/03/04
Raw View
Alexander Krotoff wrote:
>
> This is about 2nd CD section 16.3.5 [cpp.scope] pagraph 6.
>
> In the example symbol `@' is used. <detail ommitted>
> Is this example incorrect ?
>
> Thank you in advance,
> Alexander.
> ---
The @ is just part of the example argument to the str macro.

fputs(str(strncmp("abc\0d", "abc", '\4')  /* this goes away */
                  == 0) str(: @\n), s);

i.e. str(: @\n)
becomes
": @\n"

but it's not obvious because of the "concatenation of the character
string literals" in the example.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]