This bugzilla service is closed. All entries have been migrated to
Bug 1460 - Sanitze includes for Windows
Summary: Sanitze includes for Windows
Alias: None
Product: Eigen
Classification: Unclassified
Component: Tensor (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - general Windows
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2017-08-08 21:04 UTC by neumann
Modified: 2019-12-04 17:09 UTC (History)
4 users (show)


Description neumann 2017-08-08 21:04:45 UTC

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;
#include <stdint.h>

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>
#include <time.h>

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>

this will not work in future versions of Visual Studio due to missing <unistd.h> header
Comment 1 Gael Guennebaud 2017-09-06 08:40:12 UTC
This module supports to some extent C++98 too, nonetheless, I agree that in the c++11 mode, all this mess should be bypassed.
Comment 2 Nobody 2019-12-04 17:09:21 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.