Static intialization of flexible arrays in C++
Eljay Love-Jensen
eljay@adobe.com
Mon Feb 14 12:15:00 GMT 2005
Hi Nitin,
>Flexible arrays are indeed legal.
Incorrect: they are not legal in C++98 nor C++03, and they are unspecified
behavior for C89 (and, hence, not necessarily portable).
I presume they are "indeed legal" for C99 (I haven't programmed in C since
1990, so I'm out of the loop). But you were not asking about C99, you were
asking about C++.
>I thought C++ is a superset of C and C code should compile in a C++
compiler (except for strict type checking) ..but guess not.
C++98 is *MOSTLY* a superset of C89.
C99 diverges even further from C89; and thus, further divergence and
discrepancies from C++98 (or C++03).
The C99 standardization committee made it clear that they are not beholden
to C++-isms in determining the best course-of-evolution in steering /
developing / improving the C standards.
>gcc 3.3.3 compiles it just fine. g++ 3.3.3 doesnt.
GCC for C code (and the appropriate flags) compiles C code as per the C99
(ISO 9899:1999 specification).
GCC for C++ code (and the appropriate flags) compiles C++ code pretty darn
close to C++03 (ISO 14882:2003 specification).
Those flags being such things as -pedantic, -ansi, -std={something},
-trigraphs, et cetera.
HTH,
--Eljay
More information about the Gcc-help
mailing list