Home | Libraries | People | FAQ | More |
_MSC_VER
is defined for all
Microsoft C++ compilers. Its value is the internal version number of the
compiler interpreted as a decimal number. Since a few other compilers
also define this symbol, boost provides the symbol
BOOST_MSVC
defined in
boost/config.hpp
to the value of _MSC_VER if and only if the compiler is really
Microsoft Visual C++.
The following table lists some known values.
Compiler | BOOST_MSVC value |
---|---|
Microsoft Visual C++ 6.0 SP4 | 1200 |
using
-declarationsusing
-declarations do not work.
void f(); namespace N { using ::f; } void g() { using N::f; // C2873: 'f': the symbol cannot be used in a using-declaration }
#include <stdio.h> template<class T> void f() { printf("%d\n", sizeof(T)); } int main() { f<double>(); // output: "1" f<char>(); // output: "1" return 0; }
for
loops should be
local to the loop's body, but it is instead local to the enclosing
block:
int main() { for(int i = 0; i < 5; ++i) ; for(int i = 0; i < 5; ++i) // C2374: 'i': Redefinition; multiple initialization ; return 0; }Workaround: Enclose the offending
for
loops in another pair of curly braces.
std::numeric_limits
template, does
not work.
struct A { static const int i = 5; // "invalid syntax for pure virtual method" };
namespace N { struct A {}; void f(A); } void g() { N::A a; f(a); // 'f': undeclared identifier }
template<class T> struct A {}; struct B { template<class T> friend struct A; // "syntax error" };
template<class T> struct A { template<class U> void f(); }; template<class T> template<class U> // "syntax error" void A<T>::f() // "T: undeclared identifier" { }Workaround: Define member templates in-line within their enclosing class.
template<class T> struct A {}; template<class T> struct B {}; template<class T> struct A<B<T> > {}; // template class was already defined as a non-templateWorkaround: In some situations where interface does not matter, member class templates can simulate partial specialization.
template<class T, typename T::result_type> // C1001: INTERNAL COMPILER ERROR: ms c1.cpp, line 1794 struct B {}; // (omit "typename" and it compiles)
wchar_t
is not built-inwchar_t
is not a built-in type.
wchar_t x; // "missing storage class or type identifier"
Library names from the <c...> headers are in the global namespace instead of namespace std.
Workaround: The header boost/config.hpp will define BOOST_NO_STDC_NAMESPACE. It can be used as follows:
# ifdef BOOST_NO_STDC_NAMESPACE namespace std { using ::abs; using ::fabs; } # endif
Because std::size_t and std::ptrdiff_t are so commonly used, the workaround for these is already provided in boost/config.hpp.