Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7731 Discussions

Why can't icc handle int declarations inside for loops?

segmentation_fault
New Contributor I
370 Views

I am getting this error below when using the latest and greatest icc. Surely it should be able to handle this situation? I did some googling and seems it has to do with C99 standard. I guess I am confused on why this isn't the default nowadays?

 

 

/pastix/build/kernels/core_crqrrt.c(234): error: expected an expression
              for(int i=0; i<2; i++)
                  ^
/pastix/build/kernels/core_crqrrt.c(234): error: identifier "i" is undefined
              for(int i=0; i<2; i++)

 

 

0 Kudos
1 Solution
ShanmukhS_Intel
Moderator
333 Views

Hi,


Thanks for reaching out to us.


We would like to inform you that, icc can handle int declarations inside for loops. However, if your current std standard is configured to std version older than c99, you would face issues like below. (mentioned by you).

error: expected an expression / error: identifier "i" is undefined


We would like to suggest you to use icc compiler with -std version c99 or the other latest versions so that the code compiles successfully.


Best Regards,

Shanmukh.SS


View solution in original post

2 Replies
ShanmukhS_Intel
Moderator
334 Views

Hi,


Thanks for reaching out to us.


We would like to inform you that, icc can handle int declarations inside for loops. However, if your current std standard is configured to std version older than c99, you would face issues like below. (mentioned by you).

error: expected an expression / error: identifier "i" is undefined


We would like to suggest you to use icc compiler with -std version c99 or the other latest versions so that the code compiles successfully.


Best Regards,

Shanmukh.SS


ShanmukhS_Intel
Moderator
298 Views

Hi,


Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS


Reply