Hi all,

I have a small piece of code which calls _controlfp(_PC_64,_MCW_PC) and _controlfp(_PC_53,_MCW_PC) on Windows. Unfortunately, these are not provided by the <float.h> include.

Looking around the system, I find two versions of this include:
* /mingw32/i686-w64-mingw32/include/float.h
* /mingw64/x86_64-w64-mingw32/include/float.h
which are identical and contains the function and the #define, and
* /mingw32/lib/gcc/i686-w64-mingw32/5.3.0/include/float.h
* /mingw64/lib/gcc/x86_64-w64-mingw32/5.3.0/include/float.h
which do not.

Running gcc in verbose mode reveals that the problem is the order of the include paths ( I removed the "#" before the include "..." search starts here and the include <...> search starts here in order to avoid formatting problems:
include "..." search starts here: include <...> search starts here: . C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/include C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../include C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/include-fixed C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/include End of search list.

From what I have read on the net, C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/include is the CYGWIN header (should work), and C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/include is the GCC header (broken). See also https://www.cygwin.com/ml/cygwin/2003-07/msg00523.html

Is this some sort of configuration issue, or is there something I should do in the makefile etc.? I'll rather avoid hardcoding paths etc. in our build system...

Cheers,
Kyrre


The full output of gcc -v etc. :

Using built-in specs. COLLECT_GCC=C:\msys64\mingw32\bin\gcc.exe Target: i686-w64-mingw32 Configured with: ../gcc-5.3.0/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --with-gxx-include-dir=/mingw32/include/c++/5.3.0 --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='Rev4, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2 Thread model: posix gcc version 5.3.0 (Rev4, Built by MSYS2 project) COLLECT_GCC_OPTIONS='-D' 'LINUX_INLINE' '-D' 'HAVE_CONFIG_H' '-I' '.' '-fPIC' '-std=c99' '-Wall' '-Wshadow' '-Wpointer-arith' '-Wcast-align' '-Wconversion' '-Waggregate-return' '-Wstrict-prototypes' '-Wnested-externs' '-Wlong-long' '-Winline' '-Wpedantic' '-fno-strict-aliasing' '-g' '-O2' '-m32' '-mfpmath=sse' '-msse2' '-v' '-o' 'SixTrack_4535_cernlib_crlibm_fast_gfortran_m32_tilt_vvector_O3/crlibm/disable_xp.o' '-c' '-mtune=generic' '-march=i686' C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/cc1.exe -quiet -v -I . -iprefix C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/ -D_REENTRANT -D LINUX_INLINE -D HAVE_CONFIG_H crlibm/disable_xp.c -quiet -dumpbase disable_xp.c -m32 -mfpmath=sse -msse2 -mtune=generic -march=i686 -auxbase-strip SixTrack_4535_cernlib_crlibm_fast_gfortran_m32_tilt_vvector_O3/crlibm/disable_xp.o -g -O2 -Wall -Wshadow -Wpointer-arith -Wcast-align -Wconversion -Waggregate-return -Wstrict-prototypes -Wnested-externs -Wlong-long -Winline -Wpedantic -std=c99 -version -fPIC -fno-strict-aliasing -o C:\msys64\tmp\ccwMzLgf.s GNU C99 (Rev4, Built by MSYS2 project) version 5.3.0 (i686-w64-mingw32) `` compiled by GNU C version 5.3.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/5.3.0/include" ignoring nonexistent directory "C:/building/msys64/mingw32/include" ignoring nonexistent directory "/mingw32/include" ignoring duplicate directory "C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/5.3.0/include-fixed" ignoring duplicate directory "C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/include" ignoring nonexistent directory "C:/building/msys64/mingw32/i686-w64-mingw32/include" ``#include "..." search starts here: ``#include <...> search starts here: . C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/include C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../include C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/include-fixed C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/include End of search list. crlibm/disable_xp.c:1:0: warning: -fPIC ignored for target (all code is position independent) /* Initialise the IA32/64 FPU flags from Fortran */ ^ GNU C99 (Rev4, Built by MSYS2 project) version 5.3.0 (i686-w64-mingw32) `` compiled by GNU C version 5.3.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 2259d56aa242d532895d69471e33357f crlibm/disable_xp.c: In function 'disable_xp_': crlibm/disable_xp.c:17:3: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration] _controlfp(_PC_53, _MCW_PC); ^ crlibm/disable_xp.c:17:3: warning: nested extern declaration of '_controlfp' [-Wnested-externs] crlibm/disable_xp.c:17:14: error: '_PC_53' undeclared (first use in this function) _controlfp(_PC_53, _MCW_PC); ^ crlibm/disable_xp.c:17:14: note: each undeclared identifier is reported only once for each function it appears in crlibm/disable_xp.c:17:22: error: '_MCW_PC' undeclared (first use in this function) _controlfp(_PC_53, _MCW_PC); ^


Example source:

`
/ Initialise the IA32/64 FPU flags from Fortran /
/ An init function which sets FPU flags when needed /

``#ifdef APPLE

void disable_xp_(void)
{
}

``#elif defined(_WIN32) //_WIN32 means we're not running 16-bit Windows, i.e. it can be either 32- or 64-bit.

``#include <float.h>

void disable_xp_(void)
{
#ifndef _WIN64 _controlfp(_PC_53, _MCW_PC);#endif
}

``#else

``#include <fpu_control.h>

void disable_xp_(void)
{
/ Set FPU flags to use double, not double extended,
`` with rounding to nearest
/
short unsigned int cw = (_FPU_DEFAULT & ~_FPU_EXTENDED)|_FPU_DOUBLE;
_FPU_SETCW(cw);
}

``#endif

`

 

Last edit: Kyrre Ness Sjøbæk 2016-07-07