dark
dark

Reputation: 167

GCC doesn't see __VA_ARGS__ as an argument in macro

I have next code, which throws an error

expected ';' before '(' token

in string with directive "using".

#define D1(Name, ... ) \
class Name##Postfix \
{ \
    using A1 = void (*)(__VA_ARGS__); \  
};

int main()
{
    D1(test, test1);
}

If I change __VA_ARGS__ to int, then there is no error. I'm using the GCC (g++) compiler, if it's necessary.

Upvotes: 1

Views: 161

Answers (1)

gudok
gudok

Reputation: 4189

There are 3 problems with your code:

  1. test1 is not a type
  2. Spaces after backslash in "using A1" line (warning)
  3. using as type alias is supported only starting with C++11

If you fix these problems, then it compiles fine (gcc 4.9.2).

Upvotes: 3

Related Questions