Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

[windows] math.h warnings when using cl from Intel Env (cmd)

Satish_B_
Beginner
784 Views

I have the following installation:

- Windows 10

- Visual Studio 2015 (community edition)

- Intel 17.0 Update 1 (parallel studio xe composer edition for fortran and C++)

There are reasons to use  VS/cl with ParallelStudio/ifort. Here is a simple code that compiles cleanly with cl with "Visual Studio 2015 x64 Native Tools Command Prompt" - but gives warnings with "Compiler 17.0 Update 1 for Intel 64 Visual Studio 2015 environment"

######  VS CMD ################################

C:\cygwin64\home\balay\junk>type mathtest.c
#include <math.h>
int main() {
  return 0;
}

C:\cygwin64\home\balay\junk>cl mathtest.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

mathtest.c
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:mathtest.exe
mathtest.obj

C:\cygwin64\home\balay\junk>

######## Intel CMD #####################################################

c:\cygwin64\home\balay\junk>icl mathtest.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

mathtest.c
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:mathtest.exe
mathtest.obj

c:\cygwin64\home\balay\junk>cl mathtest.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

mathtest.c
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\compiler\include\math.h(1577): warning C4005: 'HUGE_VALF': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\../ucrt/math.h(80): note: see previous definition of 'HUGE_VALF'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\compiler\include\math.h(1579): warning C4005: 'HUGE_VALL': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\../ucrt/math.h(81): note: see previous definition of 'HUGE_VALL'
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\compiler\include\math.h(1581): warning C4005: 'HUGE_VAL': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\../ucrt/math.h(79): note: see previous definition of 'HUGE_VAL'
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:mathtest.exe
mathtest.obj

c:\cygwin64\home\balay\junk>

Perhaps a bug in Intel include files?

0 Kudos
5 Replies
Satish_B_
Beginner
784 Views

I'm using the following change - to avoid this issue..

--- "C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\compiler\\include\\math.h.orig"       2016-10-06 10:17:16.000000000 -0700
+++ "C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\compiler\\include\\math.h"    2016-12-10 15:26:03.586355000 -0800
@@ -164,7 +164,7 @@
 #define NAN (*((float *)__libm_qnan))
 #endif
 
-#if (!defined(__linux__) && !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__QNX__) && !defined(__VXWORKS__)) || defined(__PURE_INTEL_C99_HEADERS__)
+#if defined(__INTEL_COMPILER) && ((!defined(__linux__) && !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__QNX__) && !defined(__VXWORKS__)) || defined(__PURE_INTEL_C99_HEADERS__))
 static unsigned int __libm_huge_valf[] = {0x7f800000};
 #define HUGE_VALF (*((float *)__libm_huge_valf))
 static unsigned int __libm_huge_vall[] = {0x00000000, 0x80000000, 0x00007fff, 0};
@@ -1572,7 +1572,7 @@
 
 #define _LIBIMF_DBL_XDBL    _LIBIMF_DOUBLE
 
-#if (!defined(__linux__) && !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__QNX__) && !defined(__VXWORKS__)) || defined(__PURE_INTEL_C99_HEADERS__)
+#if defined(__INTEL_COMPILER) && ((!defined(__linux__) && !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__QNX__) && !defined(__VXWORKS__)) || defined(__PURE_INTEL_C99_HEADERS__))
 static unsigned int __libm_huge_valf[] = {0x7f800000};
 #define HUGE_VALF (*((float *)__libm_huge_valf))
 static unsigned int __libm_huge_vall[] = {0x00000000, 0x80000000, 0x00007fff, 0};


 

0 Kudos
MalReddy_Y_Intel
Employee
784 Views

Hi Satish,

Thanks for reporting your issue, I have escalated this issue to engineering team.

thanks,

Reddy

 

0 Kudos
NI_V_
Beginner
784 Views

I have the similar issue with Visual Studio 2015 and ICC 2017 Update1. I too get this build error:

c:/P4V/Perforce/build/targets/icc/17/export/17.0/170~1.3F0/tools/windows/compiler/include/math.h(1578): error #47: incompatible redefinition of macro "HUGE_VAL" (declared at line 79 of "c:/P4V/Perforce/build/targets/ms/sdk/10/export/10.0/10.0.0f0/tools/windows/allproc/include/ucrt/math.h")
  #define HUGE_VAL (*((double *)__libm_huge_val))

 

Can anyone suggest a workaround or a solution for the above issue?

0 Kudos
TimP
Honored Contributor III
784 Views
Other than the workarounds in this thread , you could upgrade your compiler.
0 Kudos
Jingwei_Z_Intel
Employee
784 Views

The problem with HUGE_VAL's has been fixed in Intel C++ Compiler 2018 update 1.

As pointed out by the compiler, it is a warning about incompatible macro definition. The definitions from MSVC and Intel ICL are both correct according to the C99/C11 standard. They are just not compatible to each other.

Thanks,

Jingwei

0 Kudos
Reply