#5459 closed defect (fixed)
VRT: vrtsources.cpp doesn't compile with mingw(-w64) in C++11 mode
Reported by: | akhliustov | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 2.0.0 |
Component: | ConfigBuild | Version: | unspecified |
Severity: | normal | Keywords: | CPL, VRT |
Cc: |
Description
The file includes <algorithm> (http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/vrt/vrtsources.cpp#L37).
It includes <bits/stl_algo.h> (http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/algorithm?view=markup#l62), which includes <random> (http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/bits/stl_algo.h?view=markup#l66), which includes <cmath> (http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/random?view=markup#l38), which undefines isnan (http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/c_global/cmath?view=markup#l545) and leaves only std::isnan.
It makes lines with CPLIsNan (http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/vrt/vrtsources.cpp#L1255 etc.) fail to compile.
Change History (6)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
An investigation shows that the problem may be caused by an interaction between libstdc++ and glibc: the latter not only defines isnan as a macro but also declares it as a function (see <bits/mathcalls.h>) and that symbol survives the inclusion of <cmath>.
One of the affected configurations is mingw-w64; it doesn't use glibc and its <math.h> doesn't declare isnan as a function.
I'll have a look at another configuration (a variant of RHEL 6) on monday.
comment:3 by , 10 years ago
Summary: | VRT: vrtsources.cpp doesn't compile with libstdc++ in C++11 mode → VRT: vrtsources.cpp doesn't compile with mingw(-w64) in C++11 mode |
---|
Well, the issue seems to be mingw(-w64)-specific, so I've changed the summary.
comment:4 by , 10 years ago
Anyway, the workaround is to move #include <algorithm> and the definition of VRTComplexSource::LookupValue (which uses std::lower_bound) to the end of the file.
comment:5 by , 10 years ago
Component: | GDAL_Raster → ConfigBuild |
---|---|
Milestone: | → 2.0 |
Resolution: | → fixed |
Status: | new → closed |
On Ubuntu 12.04 with clang 3.4, I've configured with
CC="/home/vagrant/clang+llvm-3.4-x86_64-unknown-ubuntu12.04/bin/clang" CXX="/home/vagrant/clang+llvm-3.4-x86_64-unknown-ubuntu12.04/bin/clang++ -std=c++11" ./configure
and found 2 errors (not really related with c+11 by the way) and fixed them in r27279, but it didn't report any issue with vrtsources.cpp