Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > A variation of #

Reply
Thread Tools

A variation of #

 
 
lawrence.jones@siemens.com
Guest
Posts: n/a
 
      11-08-2011
James Kuyper <> wrote:
>
> I hadn't considered that issue, but taking a look at 6.10.3.3p3, I found
> that it says "each each instance of a ## preprocessing token
> in the replacement list (not from an argument) is deleted and the
> preceding preprocessing token is concatenated with the following
> preprocessing token. ... If the result is not a valid preprocessing
> token, the behavior is undefined." It seems to me ambiguous whether "the
> result" it refers to is the result of each concatenation, or the
> combined result of all of the concatenations.


I think it's pretty clear from context that it's talking about each
replacement individually. For a token-based preprocessor, you either
need each result to be a token or you need the concept of executing a
bunch of operators in parallel (which we don't have in C).
--
Larry Jones

Hey! What's the matter? Can't you take a joke?! It was a JOKE! -- Calvin
 
Reply With Quote
 
 
 
 
Harald van Dijk
Guest
Posts: n/a
 
      11-08-2011
On Nov 7, 11:53*pm, lawrence.jo...@siemens.com wrote:
> James Kuyper <jameskuy...@verizon.net> wrote:
> > #include <stdlib.h>
> > #define TRICAT(a, b, c) a ## b ## c
> > #define CHAR(a, b, c) TRICAT(a, b, c)

>
> > #define CASE1 x

>
> ...
> > * * case CHAR('
> > * * * * , CASE1, '
> > * * * * ): break;

>
> Nice try, but no cigar. *The ## operator requires that the result be a
> valid pp-token and, depending on the order in which the operators are
> evaluated, you either end up with 'x or x', neither of which are valid
> pp-tokens.


Even if ## were redefined so that intermediate results of a ## b ## c
are ignored, the behaviour is explicitly undefined.

6.4:
preprocessing-token:
[...]
each non-white-space character that cannot be one of the above

6.4p3:
If a ' or a " character matches the last category, the behavior is
undefined.
 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      11-08-2011
On 11/08/2011 12:01 PM, Harald van Dijk wrote:
> On Nov 7, 11:53 pm, lawrence.jo...@siemens.com wrote:
>> James Kuyper <jameskuy...@verizon.net> wrote:
>>> #include <stdlib.h>
>>> #define TRICAT(a, b, c) a ## b ## c
>>> #define CHAR(a, b, c) TRICAT(a, b, c)

>>
>>> #define CASE1 x

>>
>> ...
>>> case CHAR('
>>> , CASE1, '
>>> ): break;

>>
>> Nice try, but no cigar. The ## operator requires that the result be a
>> valid pp-token and, depending on the order in which the operators are
>> evaluated, you either end up with 'x or x', neither of which are valid
>> pp-tokens.

>
> Even if ## were redefined so that intermediate results of a ## b ## c
> are ignored, the behaviour is explicitly undefined.
>
> 6.4:
> preprocessing-token:
> [...]
> each non-white-space character that cannot be one of the above
>
> 6.4p3:
> If a ' or a " character matches the last category, the behavior is
> undefined.


Yes, I forgot about that item, too.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
variation on (?) call subroutine by reference Alison Bowes Perl 0 02-18-2005 05:39 PM
Li-Ion batt for D70: vast variation in price MB Digital Photography 11 11-21-2004 03:34 PM
Severe Light Variation Bob Daun Digital Photography 4 08-05-2004 09:52 PM
Travelling salesman variation in python Erlend Andreas Garberg Python 20 04-02-2004 09:09 PM
New Sobig variation on the loose W32/Sobig.F-mm Lord Shaolin Computer Security 7 08-21-2003 11:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57