Bug 18171 - Problem with varargs in #define-macro
Summary: Problem with varargs in #define-macro
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 2.95.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-27 08:38 UTC by ingemar.fransson
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ingemar.fransson 2004-10-27 08:38:46 UTC
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__ ,"
Comment 1 Andrew Pinski 2004-10-27 11:32:23 UTC
2.95.x is not going to be updated/changed.