This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Why does this happen ??
On Thu, Nov 30, 2000 at 04:11:37PM -0200, Alexandre Oliva wrote:
> On Nov 30, 2000, Davy Durham <david.durham@wcom.com> wrote:
>
> > char s[]="Hello World";
>
> > this will make a stack array of 11+1 chars containing "Hello World"
>
> Initializing an automatic array isn't permitted in ISO C,
> unfortunately. GCC supports it as an extension.
You are thinking of pre-ISO compilers that only allow initialization of auto
scalar members. ISC C89 (and presumably C99) does allow initialization of auto
arrays and structures (though if you aren't going to modify it, you should
declare it static to avoid having to do the copy at runtime). What is a GCC
extension to C89 (I don't remember about C99) is an initialization to an
array/struct that doesn't involve static members:
int foo(int i){
auto struct bar { int a, int b; } s = { i, 0 };
}
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482