This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: gcc v msvc anomaly
- From: lrtaylor at micron dot com
- To: <kalinabears at iinet dot net dot au>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 27 Jan 2005 16:33:29 -0700
- Subject: RE: gcc v msvc anomaly
That syntax may be valid for C99 compliant code, but is not valid for
earlier versions of C. I believe GCC supports the C99 standard. The
Microsoft compiler likely doesn't, especially if you're using Visual
Studio 6, which I believe was released around 1998 or so (according to
the about box anyway). So, neither compiler is necessarily wrong - they
just support different versions of the C standard.
Thanks,
Lyle
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Sisyphus
Sent: Thursday, January 27, 2005 2:59 PM
To: gcc
Subject: gcc v msvc anomaly
Hi,
--- alloc.c ---
#include <stdio.h>
int main() {
int i, c = 5, j[c];
for(i = 0; i < c; ++i) {
j[i] = i;
printf("%d ", j[i]);
}
printf("\n");
return 0;
}
--------------
Should that simple script compile and run as expected ?
With my MinGW port of gcc it does - but with Microsoft compilers it
won't even compile. I get:
alloc.c(4) : error C2057: expected constant expression
alloc.c(4) : error C2466: cannot allocate an array of constant size 0
alloc.c(4) : error C2133: 'j' : unknown size
Is the Microsoft compiler right in rejecting the code ? If so, has the
issue been addressed in later versions of gcc ?
Cheers,
Rob