Patch by Kenneth Riddile: disable MSVC warnings, reenable them outside

of Eigen, and add a MSVC-friendly path in StaticAssert.
This commit is contained in:
Benoit Jacob 2008-12-18 20:48:02 +00:00
parent fabaa6915b
commit 8106d35408
11 changed files with 56 additions and 4 deletions

View File

@ -3,6 +3,8 @@
#include "Core" #include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen { namespace Eigen {
/** \defgroup Array Array module /** \defgroup Array Array module
@ -32,4 +34,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_ARRAY_MODULE_H #endif // EIGEN_ARRAY_MODULE_H

View File

@ -3,6 +3,8 @@
#include "Core" #include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module // Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
#if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2) #if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2)
#ifndef EIGEN_HIDE_HEAVY_CODE #ifndef EIGEN_HIDE_HEAVY_CODE
@ -57,4 +59,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#endif #endif
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_CHOLESKY_MODULE_H #endif // EIGEN_CHOLESKY_MODULE_H

View File

@ -2,8 +2,8 @@
#define EIGEN_CORE_H #define EIGEN_CORE_H
// first thing Eigen does: prevent MSVC from committing suicide // first thing Eigen does: prevent MSVC from committing suicide
#include "src/Core/util/DisableMSVCWarnings.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning( disable : 4181 4244 )
#if (_MSC_VER >= 1500) // 2008 or later #if (_MSC_VER >= 1500) // 2008 or later
// Remember that usage of defined() in a #define is undefined by the standard // Remember that usage of defined() in a #define is undefined by the standard
#ifdef _M_IX86_FP #ifdef _M_IX86_FP
@ -144,4 +144,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_CORE_H #endif // EIGEN_CORE_H

View File

@ -1,6 +1,10 @@
#ifndef EIGEN_GEOMETRY_MODULE_H #ifndef EIGEN_GEOMETRY_MODULE_H
#define EIGEN_GEOMETRY_MODULE_H #define EIGEN_GEOMETRY_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include "Array" #include "Array"
#include <limits> #include <limits>
@ -39,4 +43,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_GEOMETRY_MODULE_H #endif // EIGEN_GEOMETRY_MODULE_H

View File

@ -3,6 +3,8 @@
#include "Core" #include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen { namespace Eigen {
/** \defgroup LU_Module LU module /** \defgroup LU_Module LU module
@ -22,4 +24,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_LU_MODULE_H #endif // EIGEN_LU_MODULE_H

View File

@ -2,6 +2,9 @@
#define EIGEN_QR_MODULE_H #define EIGEN_QR_MODULE_H
#include "Core" #include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include "Cholesky" #include "Cholesky"
// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module // Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
@ -62,4 +65,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_QR_MODULE_H #endif // EIGEN_QR_MODULE_H

View File

@ -1,6 +1,10 @@
#ifndef EIGEN_REGRESSION_MODULE_H #ifndef EIGEN_REGRESSION_MODULE_H
#define EIGEN_REGRESSION_MODULE_H #define EIGEN_REGRESSION_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include "LU" #include "LU"
#include "QR" #include "QR"
#include "Geometry" #include "Geometry"
@ -19,4 +23,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_REGRESSION_MODULE_H #endif // EIGEN_REGRESSION_MODULE_H

View File

@ -3,6 +3,8 @@
#include "Core" #include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen { namespace Eigen {
/** \defgroup SVD_Module SVD module /** \defgroup SVD_Module SVD module
@ -19,4 +21,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_SVD_MODULE_H #endif // EIGEN_SVD_MODULE_H

View File

@ -2,6 +2,9 @@
#define EIGEN_SPARSE_MODULE_H #define EIGEN_SPARSE_MODULE_H
#include "Core" #include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include <vector> #include <vector>
#include <map> #include <map>
#include <cstdlib> #include <cstdlib>
@ -102,4 +105,6 @@ namespace Eigen {
} // namespace Eigen } // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_SPARSE_MODULE_H #endif // EIGEN_SPARSE_MODULE_H

View File

@ -74,8 +74,20 @@
}; };
}; };
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ // Specialized implementation for MSVC to avoid "conditional
if (Eigen::ei_static_assert<CONDITION ? true : false>::MSG) {} // expression is constant" warnings. This implementation doesn't
// appear to work under GCC, hence the multiple implementations.
#ifdef _MSC_VER
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
{Eigen::ei_static_assert<CONDITION ? true : false>::MSG;}
#else
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
if (Eigen::ei_static_assert<CONDITION ? true : false>::MSG) {}
#endif
#endif // not CXX0X #endif // not CXX0X

View File

@ -279,7 +279,7 @@ inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const Quaternion& other
template<typename Scalar> template<typename Scalar>
inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const AngleAxisType& aa) inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const AngleAxisType& aa)
{ {
Scalar ha = 0.5*aa.angle(); Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
this->w() = ei_cos(ha); this->w() = ei_cos(ha);
this->vec() = ei_sin(ha) * aa.axis(); this->vec() = ei_sin(ha) * aa.axis();
return *this; return *this;