This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static array size


Thanks Dave. So it is safe to use variable length array in C program on linux machine, and I suppose all GCC on linux machines conform C99 although I never switch my C compilation to C99.

Thanks and sorry for FAQ questions.

Jim

Dave Korn wrote:

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]