I\'m trying to build googletest with Visual C++ 11, but following code causes an error
template
Add below line into your cmake file
add_definitions(/D_VARIADIC_MAX=10)
In Visual Studio 2013, std::tuple
no longer uses _VARIADIC_MAX
and now uses actual variardic template
s, so this problem should be gone.
If you run into it in 2013, it means you are including the wrong standard library.
Setting GTEST_HAS_TR1_TUPLE
to 0 in gtest.h helped in my case
Update: of course, the less intrusive way is to define a precompiler flag GTEST_HAS_TR1_TUPLE=0. Check the answers about _VARIADIC_MAX=10
- solves another half of the issue.
Check out this entry in the msdn blog. VC++11 doesn't have support for variadic templates. They have something they call faux variadics. Scroll down and you will see a paragraph on Faux variadics that talks about tuples. On that paragraph they say the default maximum number of parameters is 5. You can increase it to 10:
You can define _VARIADIC_MAX project-wide between 5 and 10 inclusive (it defaults to 5). Increasing it will make the compiler consume more memory, and may require you to use the /Zm option to reserve more space for PCHes.
They say they have a fix incoming to make the default 10 again.
In Visual Studio 2012 (VC11) _VARIADIC_MAX
is by default defined as 5 in header <xstddef>
:
#if !defined(_VARIADIC_MAX)
#define _VARIADIC_MAX 5
#elif _VARIADIC_MAX < 5 || 10 < _VARIADIC_MAX
#error _VARIADIC_MAX must be between 5 and 10, inclusive
#endif /* !defined(_VARIADIC_MAX) */
if you have multiple VC11 projects include <tuple>
in a solution, it is better to set the macro to all by
1) Shift click to select all C++ projects in your solution
2) Properties, C/C++, Preprocessor, All Configurations All Platforms, Preprocessor Definitions, <Edit>
3) add before <different options>
a row
_VARIADIC_MAX=10;
You can change 10 to any number in 6~10.
This is fixed in version r675. See https://code.google.com/p/googletest/source/detail?r=675