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....