Skip to content

Missing __VA_ARGS__ extension in Microsoft mode #13217

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 12845
Resolution FIXED
Resolved on May 17, 2018 09:16
Version trunk
OS Windows NT
Blocks llvm/llvm-bugzilla-archive#13707
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic,@tritao,@nico

Extended Description

When passing a single argument to a macro which defines a function with a variable arguments list as its' second argument, Clang will incorrectly preprocess such code, leaving the unnecessary comma after the first argument, thus making the resulting code uncompilable. Consider the example:

bool MsgAlert(bool yes_no, int Style, const char* format, ...)
{return true;}
#define PanicAlert(format, ...) MsgAlert(false, 1, format, VA_ARGS)

void func()
{PanicAlert("text");}

Clang preprocessor (the -E flag, in MS compatibility mode) will generate the following (note the excessive comma after "text"):

void func()
{MsgAlert(false, 1, "text", );}

In comparison, the MSVC preprocessor (cl.exe) will generate the correct code:

void func()
{MsgAlert(false, 1, "text" );}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions