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

Compiling mixed C++ and C99 code

madiyaan
Beginner
752 Views
I am using icc version 11 that I downloaded off the internet. The platform I am using is Windows XP. I want to be able to compile C++ code that has some C99 features like variable length arrays etc.

I have been told that g++ can compile this code just fine with the default options (though you can specify a switch that will disable C99 support when compiling C++ code. Unfortunately I can't use g++ because I am using the Windows platform.

My question is this: is there an option that will let me compile this kind of code using icc without rewriting any part of the code?

Thanks,
0 Kudos
10 Replies
aazue
New Contributor I
752 Views
Quoting - madiyaan
I am using icc version 11 that I downloaded off the internet. The platform I am using is Windows XP. I want to be able to compile C++ code that has some C99 features like variable length arrays etc.

I have been told that g++ can compile this code just fine with the default options (though you can specify a switch that will disable C99 support when compiling C++ code. Unfortunately I can't use g++ because I am using the Windows platform.

My question is this: is there an option that will let me compile this kind of code using icc without rewriting any part of the code?

Thanks,

Hi

(Unfortunately I can't use g++ because I am using the Windows platform
.)

I think you can use gcc or g++ Windows platform.
See here you having links download and explains howto make

http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite#comment-206

Best regards

Added:

icc I don't know (never tested Intel compiler (no great experience icc)
Depended your Makefile parameters, you can make this test ?? (env)
CC=icc -std=c99
CFLAGS= ....
CXX=icpc
CXXFLAGS= ....
.....
My experience same you can crossing 2 versions compiler (GNU gcc-xxx & g++-xxx)
used when (last snapshot version g++) problems.

Wait an other answer,origin user large experience icc before, is better.

See here you having an small similar discuss of this subject.

https://stat.ethz.ch/pipermail/r-help/2008-February/154278.html
Best regards
0 Kudos
Om_S_Intel
Employee
752 Views
Quoting - madiyaan
I am using icc version 11 that I downloaded off the internet. The platform I am using is Windows XP. I want to be able to compile C++ code that has some C99 features like variable length arrays etc.

I have been told that g++ can compile this code just fine with the default options (though you can specify a switch that will disable C99 support when compiling C++ code. Unfortunately I can't use g++ because I am using the Windows platform.

My question is this: is there an option that will let me compile this kind of code using icc without rewriting any part of the code?

Thanks,

You may try Intel C++ compiler 11.0option /Qstd:c99 to get C99 support.
0 Kudos
Claudiu_Gilcescu-Cei
752 Views
Quoting - madiyaan
I have been told that g++ can compile this code just fine with the default options (though you can specify a switch that will disable C99 support when compiling C++ code. Unfortunately I can't use g++ because I am using the Windows platform.

Bustaf is right, you can use gcc in Windows. I compiled mixed code with MinGW and never had any problems, installation should be easy, I don't think you'll have difficulties there.

Best regards,
Claudiu
0 Kudos
srimks
New Contributor II
752 Views
Quoting - madiyaan
I am using icc version 11 that I downloaded off the internet. The platform I am using is Windows XP. I want to be able to compile C++ code that has some C99 features like variable length arrays etc.

I have been told that g++ can compile this code just fine with the default options (though you can specify a switch that will disable C99 support when compiling C++ code. Unfortunately I can't use g++ because I am using the Windows platform.

My question is this: is there an option that will let me compile this kind of code using icc without rewriting any part of the code?

Thanks,
Intel C++ Compiler (v-11.0) can compile "variable length arrays" as asked by you, apart from this it can also compile below C99 features too -

restricted pointers (restrict keyword).
flexible array members
complex number support (_Complex keyword)
hexadecimal floating-point constants
compound literals
designated initializers
mixed declarations and code
macros with a variable number of arguments
inline functions (inline keyword)
boolean type (_Bool keyword)

~BR
Mukkaysh


0 Kudos
Bob_Hayes
Beginner
752 Views
I have icl ver 9.1, VS 6.0, and WinXP SP2.

I have specified the /Qstd=c99 command line switch, but the following won't compile without error:

for (int i = 0; i < sizeof (ChamberTemp); i++) *pRecord++ = ' ';

The compiler claims that i is undefined.

This is from a C module.

This is mixed code and declarations (a C99 feature) but it's not working.

Does Intel C++ for Windows ver 9.1 support C99 features? It seems to accept the /Qstd=c99 switch without complaint.


0 Kudos
TimP
Black Belt
752 Views
Quoting - Bob Hayes
I have icl ver 9.1, VS 6.0, and WinXP SP2.

I have specified the /Qstd=c99 command line switch, but the following won't compile without error:

for (int i = 0; i < sizeof (ChamberTemp); i++) *pRecord++ = ' ';

The compiler claims that i is undefined.
I don't have the 9.1 documents installed; I hope you do. This much C99 ought to be implemented, but maybe with a different switch spelling, such as /Qc99. Your switch is correct for recent compilers. I find this definition quite useful, particularly with OpenMP.
0 Kudos
Bob_Hayes
Beginner
752 Views
Quoting - tim18
I don't have the 9.1 documents installed; I hope you do. This much C99 ought to be implemented, but maybe with a different switch spelling, such as /Qc99. Your switch is correct for recent compilers. I find this definition quite useful, particularly with OpenMP.

I do, and 9.1 docs claim c99 support with that switch, I've tried it /Qstd=c99 /Qstd:c99, no difference, won't compile

for (int i =0; i < n; i++) {} without complaining about i undefined.

I do like the C99 features, most particulalry being free to declare variables anywhere in a block rather than just at the top.


0 Kudos
Bob_Hayes
Beginner
752 Views
Quoting - Bob Hayes

I do, and 9.1 docs claim c99 support with that switch, I've tried it /Qstd=c99 /Qstd:c99, no difference, won't compile

for (int i =0; i < n; i++) {} without complaining about i undefined.

I do like the C99 features, most particulalry being free to declare variables anywhere in a block rather than just at the top.



I have build 9.1.028, I saw somewhere here in KB a reference to a C99 problem fixed in build 9.1.030. Maybe I can find that build somewhere and download it.
0 Kudos
Om_S_Intel
Employee
752 Views
Quoting - Bob Hayes

I have build 9.1.028, I saw somewhere here in KB a reference to a C99 problem fixed in build 9.1.030. Maybe I can find that build somewhere and download it.

I have tried Intel C++ 9.1.037 and it works.

C:>type tstcase.cpp

void foo()
{
char ChamberTemp[1000];
char *pRecord;

for (int i = 0; i < sizeof (ChamberTemp); i++) *pRecord++ = ' ';
}

C:>icl -c tstcase.cpp
Intel C++ Compiler for 32-bit applications, Version 9.1 Build 20070322Z Package ID: W_CC_C_9.1.037
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

tstcase.cpp
0 Kudos
Bob_Hayes
Beginner
752 Views

I have tried Intel C++ 9.1.037 and it works.

C:>type tstcase.cpp

void foo()
{
char ChamberTemp[1000];
char *pRecord;

for (int i = 0; i < sizeof (ChamberTemp); i++) *pRecord++ = ' ';
}

C:>icl -c tstcase.cpp
Intel C++ Compiler for 32-bit applications, Version 9.1 Build 20070322Z Package ID: W_CC_C_9.1.037
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

tstcase.cpp


I managed to download and install C++ 10.0.025 and the problem went away.

Thanks for the support.
0 Kudos
Reply