I was under impression Visual C++ 10 had built-in static_assert
. However when I compile the following
void test()
{
static_assert( sizeof( char ) == 1, "" );
}
I get
error C3861: 'static_assert': identifier not found
What am I doing wrong and how do I use static_assert
in Visual C++ 10?
The reason was Visual Studio was set up to use Visual C++ 9 compiler (the one which is shipped with Visual Studio 2008). I don't know how it happened, perhaps the wizard configuring Visual Studio imported paths to the previous version.
The settings is changed in project properties - on "VC++ Directories" pane. The easy way to check which compiler is invoked is to add -Bv
option to the compiler command line which will make the compiler report its version.