Different behavior of Intel C Compiler on Linux/Windows

Submit New Article

September 7, 2011 12:00 AM PDT


The following sample C code compiles fine with Intel(R) C Compiler on Linux but reports error when compiled with Intel C Compiler on Windows:

int main() {

  int i;
  i = 1;
  printf("Here we go\n");
  int j;
  j = i;

}


>icl -c t.c
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1.0.233 Build 20110811
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

t.c
t.c(6): error: declaration may not appear after executable statement in block
    int j;
    ^

compilation aborted for t.c (code 2)

To be able to declare variables after executable statements rather than having to declare all of them up front you will need to compile per C99 specification using the compiler option /Qstd=c99 as shown below:

>icl -c t.c -Qstd=c99
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1.0.233 Build 20110811
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

t.c
>

 



Do you need more help?


This article applies to: Intel® C++ Compiler for Windows* Knowledge Base,   Intel® Parallel Composer Knowledge Base