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

Incompatibility between Visual C++ and Intel C++ regarding the long double type

meriko
Beginner
650 Views

Hello, 

I integrated the Intel C++ Compiler XE 2013 into Microsoft Visual Studio Professional Edition 2008 in order to be able to use long double data types with 80bit precision.

I used the /Qlong-double flag during compilation, and disabled all the optimizations available in Intel C++.

The program compiles and links without errors. However I observed that long double still doesn't work correctly.

When I print the following:

cout.precision(30);
cout<<std::numeric_limits<long double>::digits10<<endl;
cout<<std::numeric_limits<long double>::epsilon()<<endl;
cout<<sizeof(long double)<<endl;
cout<<std::numeric_limits<double>::digits10<<endl;
cout<<std::numeric_limits<double>::epsilon()<<endl;
cout<<sizeof(double)<<endl;

I get the following output:

18

-0 -->why??? 

16

15

2.2204460492503131e-016

8

Moreover, when I debug my code, I see that the types of my long double variables are unknown i.e. it shows ??? as the type instead of "long double". And when I set long double aa = 1.0; long double bb = 1e-18; the value of aa and bb are set to 0 and 2461398656 respectively. 

Can anyone help me with the problem? 

Thank you,

Meriko

0 Kudos
10 Replies
TimP
Honored Contributor III
650 Views
"compatibllity" includes the use of Microsoft headers and libraries. This is documented in the description of /Qlong-double. The operand has to be cast implicitly to double for cout. I assume you use the debugging facility provided by Microsoft which also has no provision for a long double differing from double.
0 Kudos
meriko
Beginner
650 Views
Does Intel C++ compiler have its own runtime library? I installed the Intel C++ compiler, but found out that most of the headers and libraries are absent. On Windows it is dependent on MSVC's header files and libraries I suppose. How can I use Intel's own C/C++ library? Thank you,
0 Kudos
mecej4
Honored Contributor III
650 Views
As far as I know, the Intel-supplied libraries are intended to be additions, not replacements, to the MS-supplied C libraries. The exception may be a small number of functions for which ICL supplies higher-performance versions.
0 Kudos
SergeyKostrov
Valued Contributor II
650 Views
Hi Meriko, >>...On Windows it is dependent on MSVC's header files and libraries... Please use MS Depends to verify which CRT-libraries are used. I'd like to refer you to an Intel manual: Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture download.intel.com/products/processor/manual/253665.pdf in order to get more technical information regarding a 'long double' data type. My personal recommendation is 'Do Not Use' 'long double' type and 'Use' 'double' type instead. However, I'll take a look at your test-case. Best regards, Sergey
0 Kudos
SergeyKostrov
Valued Contributor II
650 Views
>>... >>cout [left-arrow-left-arrow] sizeof(long double) [left-arrow-left-arrow] endl; >>... How did you get a value 16? It has to be 10 for Intel & Microsoft C++ compilers, and 12 for MinGW C++ compiler.
0 Kudos
TimP
Honored Contributor III
650 Views
Sergey, sizeof doesn't tell how many bits are actually used in the data type. It tells how many storage bytes are consumed. In a 64-bit OS, 80-bit long double normally is stored on 16-byte boundaries for improved performance. Of course, it still will not compete with performance of 32- or 64-bit SSE or AVX data types. 32-bit gcc normally uses 12-byte boundaries, so icc ia32 would do the same. If your preference for x87 code is specific to 32-bit mode, that's understandable, but you should still consider portability factors, or specify when your advice is specific to 32-bit "ia32" or "387" mode.
0 Kudos
meriko
Beginner
650 Views
Is Intel Compiler stand alone compiler with its own CRT libraries? Can I install Intel C++ compiler on Windows without having MCVS or Visual C++? Thank you,
0 Kudos
Bernard
Valued Contributor I
650 Views
MSVCRT run-time library does not support a long double primitive type.The only support for this type is for compatibility reason.For example MSVCRT implementation of library printf will cast long double to double before printing to stdout its value.
0 Kudos
Bernard
Valued Contributor I
650 Views
meriko You cannot by-pass Windows Msvcrt.dll runtime libraries without the drastically changing Windows infrastructure(I mean runtime libraries).Every program compiled on Win platform is dynamicaly linked with CRT-libraries.You can change compiler linking behaviour by hooking at runtime calls to CRT-functions and providing your own implementation.
0 Kudos
SergeyKostrov
Valued Contributor II
650 Views
>>...Can I install Intel C++ compiler on Windows without having MCVS or Visual C++? I think Yes, but I'll need MS linker and CRT import libraries ( to build binaries ), and MS CRT DLLs ( to execute binaries ) from a Platform SDK. In a case when VS is not installed an installer should display a warning message.
0 Kudos
Reply