gnats-prs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnats/75: cpp will not expand varargs macros when they are args to the s


From: tim
Subject: gnats/75: cpp will not expand varargs macros when they are args to the same macro
Date: 23 May 2000 01:35:40 -0000

>Number:         75
>Category:       gnats
>Synopsis:       cpp will not expand varargs macros when they are args to the 
>same macro
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 22 18:44:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Tim Conrow
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Linux 2.2.5-22 #1 Wed Jun 2 09:17:03 EDT 1999 i686 unknown
gcc version 2.95.2 19991024 (release)
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c -v -D__ELF__ -Dunix 
-D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix 
-D__linux -Asystem(posix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 
-D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro 
-D__pentiumpro__ -
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
>Description:
A varargs macro will not expand references to itself as 
arguments. E.g. 

#define  A(x,y...)  b(x , ## y ,0)

When called as

A(1, A(1,2,3), A(4,5,6)); 

... does not expand the inner calls to 'A'. But embedding
calls to *other* varargs macros works fine, as will a
similar test applied to non-varargs macros. See test
code for examples.

>How-To-Repeat:
/* mactst.c */

#define  A(x,y...)  b(x , ## y ,0)
#define  C(x,y,z)   d(x,y,z)
#define  E(x,y...)  f(x , ## y ,0)



A(1, A(1,2,3), A(4,5,6));          
C(2, C(7,8,9), C(10,11,12));       
C(3, A(1,2,3,4), A(1,2));          
A(4, C(3,2,1), C(7,6,5), C(9,8,7));
A(5, E(1,2,3), E(4,5,6));          
E(6, E(3,2,1), E(6,5,4));          



/*

Result on my machine:

% uname -a
Linux spindrift.caltech.edu 2.2.5-22 #1 Wed Jun 2 09:17:03 EDT 1999 i686 unknown
% gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)

% gcc -E mactst.c
# 1 "mactst.c"
 







b( 1  ,A(1,2,3), A(4,5,6)  ,0) ;          
d( 2 ,  d( 7 , 8 , 9 )  ,  d( 10 , 11 , 12 )  ) ;       
d( 3 ,  b( 1  ,2,3,4  ,0)  ,  b( 1  ,2  ,0)  ) ;          
b( 4  ,d( 3 , 2 , 1 ) , d( 7 , 6 , 5 ) , d( 9 , 8 , 7 )   ,0) ;
b( 5  ,f( 1  ,2,3  ,0) , f( 4  ,5,6  ,0)   ,0) ;          
f( 6  ,E(3,2,1), E(6,5,4)  ,0) ;          



 







*/
>Fix:
I'm hoping you can suggest a work-around. The only one I can
come up with is having two macros that do the same thing
and alternating their use when embedding one within the
other.
>Release-Note:
>Audit-Trail:
>Unformatted:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]