Reputation: 13575
The following code is okay on VC++ 2012
#include <algorithm>
#define MAX_OF_2(a,b) std::max(a,b)
#define FOO(a) a
// work
#define MAX2(...) FOO(MAX_OF_2(__VA_ARGS__))
// Not work
// #define MAX2(...) MAX_OF_2(__VA_ARGS__)
int main()
{
int i = MAX2(1,2);
}
It cannot compile without using FOO
macro. It shows not engough actual parameter for MAX_OF_2
. Why or any bug on compiler?
Upvotes: 2
Views: 84
Reputation: 4411
This is a known bug in msvc
In your case __VA_ARGS__
is considered as if it's a macro that needs expansion.
Upvotes: 3