This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: static array size
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: <yh at bizmail dot com dot au>, <gcc at gcc dot gnu dot org>
- Date: Mon, 24 Apr 2006 12:13:49 +0100
- Subject: RE: static array size
On 24 April 2006 12:09, YH wrote:
> Hello,
>
> Is the following example legal in current GCC compilation for C
> program? I thought the static array allocation can only used by a
Not static! That's an automatic allocation on the stack.
> defined constant such as char buf[MAX_SIZE], where #define MAX_SIZE 10?
>
> void DoSomthing(int size)
> {
> char buf[size];
>
> ...... do something ....
>
> }
>
http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Variable-Length.html#Variable-Leng
th
"Variable-length automatic arrays are allowed in ISO C99, and as an extension
GCC accepts them in C89 mode and in C++"
cheers,
DaveK
--
Can't think of a witty .sigline today....