The following code fails to compile with GCC 2.95.3, but is OK with GCC 3.3.3 
(and also GCC 2.96 from RedHat):

/* test.c:2: badly punctuated parameter list in `#define' */
#define TRACE(args ...) printf(## args)

#define log(format, args...) printf("<%s:%s:%d>, " format, __FILE__, 
__FUNCTION__, __LINE__, ## args)

int main(void)
{
    log("Log %s ...\n", "this");                
    /* test.c:10: parse error before `)' */
    log("Empty log ...\n");             
}


* <Space> after "args" and before "..." in a macro fails to compile with the 
error:
test.c:2: badly punctuated parameter list in `#define'

* "Macro-call" with empty args fails to compile with the error:
test.c:10: parse error before `)'
A <space> needs to be inserted at "__LINE__ ,"

-- 
           Summary: Problem with varargs in #define-macro
           Product: gcc
           Version: 2.95.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ingemar dot fransson at micronic dot se
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18171

Reply via email to