aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/main.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-09-15 09:18:16 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-09-15 09:18:16 -0700
commit10a79ca3a396f040c2324a5078c7e666bc904bed (patch)
tree7fb700dc5686d7b0f2687b71132bc3daa595eb9f /test/main.h
parentefdff157493826bbcc023a85e08596fd58d7997a (diff)
parent9452eb38f812194a676edc1b9eb9d08b7bc0f297 (diff)
Merged latest updates from the Eigen trunk.
Diffstat (limited to 'test/main.h')
-rw-r--r--test/main.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/main.h b/test/main.h
index 763cec8f9..b504970f3 100644
--- a/test/main.h
+++ b/test/main.h
@@ -17,13 +17,36 @@
#include <sstream>
#include <vector>
#include <typeinfo>
+
+// The following includes of STL headers have to be done _before_ the
+// definition of macros min() and max(). The reason is that many STL
+// implementations will not work properly as the min and max symbols collide
+// with the STL functions std:min() and std::max(). The STL headers may check
+// for the macro definition of min/max and issue a warning or undefine the
+// macros.
+//
+// Still, Windows defines min() and max() in windef.h as part of the regular
+// Windows system interfaces and many other Windows APIs depend on these
+// macros being available. To prevent the macro expansion of min/max and to
+// make Eigen compatible with the Windows environment all function calls of
+// std::min() and std::max() have to be written with parenthesis around the
+// function name.
+//
+// All STL headers used by Eigen should be included here. Because main.h is
+// included before any Eigen header and because the STL headers are guarded
+// against multiple inclusions, no STL header will see our own min/max macro
+// definitions.
#include <limits>
#include <algorithm>
-#include <sstream>
#include <complex>
#include <deque>
#include <queue>
+#include <list>
+// To test that all calls from Eigen code to std::min() and std::max() are
+// protected by parenthesis against macro expansion, the min()/max() macros
+// are defined here and any not-parenthesized min/max call will cause a
+// compiler error.
#define min(A,B) please_protect_your_min_with_parentheses
#define max(A,B) please_protect_your_max_with_parentheses
@@ -76,6 +99,10 @@ namespace Eigen
#define EIGEN_DEFAULT_IO_FORMAT IOFormat(4, 0, " ", "\n", "", "", "", "")
+#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__)
+ #define EIGEN_EXCEPTIONS
+#endif
+
#ifndef EIGEN_NO_ASSERTION_CHECKING
namespace Eigen
@@ -172,7 +199,7 @@ namespace Eigen
#ifndef VERIFY_RAISES_ASSERT
#define VERIFY_RAISES_ASSERT(a) \
- std::cout << "Can't VERIFY_RAISES_ASSERT( " #a " ) with exceptions disabled";
+ std::cout << "Can't VERIFY_RAISES_ASSERT( " #a " ) with exceptions disabled\n";
#endif
#if !defined(__CUDACC__)