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.
|