- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the following code (called misc.c)
#include <stdlib.h> #include <stdio.h> #include <mkl.h> #include <math.h> // double my_value = 1.0f; // Works fine. double my_value = NAN; // Gives "error: expression must have a constant value". int main () { // double my_value = NAN; // Works fine. printf("my value is %f\n", my_value); return 0; }
However, when I try to compile this using ICC (18.0.0 20170811) I get the following error:
% icc -mkl -D__PURE_INTEL_C99_HEADERS__ misc.c -o misc misc.c(6): error: expression must have a constant value double my_nan = NAN;
However, if I use GCC this works fine (after commenting out the mkl.h include line) and runs as expected.
I find this a bit strange and unexpected. Should I have expected this?
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
bash-4.2$ gcc --version gcc (GCC) 7.2.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash-4.2$ gcc misc.c -o misc -Wall -Wextra -ansi -pedantic misc.c:9:1: error: C++ style comments are not allowed in ISO C90 // double my_value = 1.0f; // Works fine. ^ misc.c:9:1: error: (this will be reported only once per input file) misc.c:10:19: error: ‘NAN’ undeclared here (not in a function) double my_value = NAN; // Gives "error: expression must have a constant value". ^~~ bash-4.2$
It think If you want icc to be more flexible you need to remove -D__PURE_INTEL_C99_HEADERS__ limitation or comply with C99 standard
Vladimir

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page