Sanitze includes for Windows
Submitted by neu..@..eck.de
Assigned to Nobody
Link to original bugzilla bug (#1460)
Version: 3.3 (current stable)
Operating system: Windows
Description
Problem:
using #include <unsupported/Eigen/CXX11/Tensor> can lead to compilation problems for Windows system due to strange include choices within the file (for example it pulls in macros for max and min which dont play well with std::min/max [properly pulled in due to #include <windows.h>])
Ofending Code:
Line 48-57:
#ifdef _WIN32
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
Why? It should by CXX11 so just include <cstdint>
Line 63-69:
#ifdef _WIN32
#include <windows.h>
#elif defined(APPLE)
#include <mach/mach_time.h>
#else
#include <time.h>
#endif
Again why? Are we CXX11 or before? Include <ctime> or (better) <chrono>
The removal of this code needs some extra work in TensorRandom header but it is easily done. (using std::random_device instead of two calls to rand() and some windows call to get a time)
Line 78-81:
#if __cplusplus >= 201103L
#include <atomic>
#include <unistd.h>
#endif
this will not work in future versions of Visual Studio due to missing <unistd.h> header