From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9ab217670603012052t733f79f8m@mail.gmail.com> Date: Wed, 1 Mar 2006 20:52:43 -0800 From: "Devon H. O'Dell" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] A Plan 9 C request.... In-Reply-To: <4405FD26.6080607@lanl.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <59a908a62c52dd9ff6252fe697d37a87@coraid.com> <4405FD26.6080607@lanl.gov> Topicbox-Message-UUID: 09780edc-ead1-11e9-9d60-3106f5b1d025 2006/3/1, Ronald G Minnich : > Brantley Coile wrote: > >>now means > >> > >> { int i; for(i=3D0; i<10; i++); } > > > > > > Does that mean the following will compile? > > > > void > > f(void) > > { > > i =3D 3; > > put(i); > > for (int i =3D 0; i < 3; i++) > > put(i); > > if (i =3D=3D 4) put(4); > > } > > > > cat > t.c > void > f(void) > { > i =3D 3; > put(i); > for (int i =3D 0; i < 3; i++) > put(i); > if (i =3D=3D 4) put(4); > } > [rminnich@q tmp]$ cc t.c > t.c: In function 'f': > t.c:4: error: 'i' undeclared (first use in this function) > t.c:4: error: (Each undeclared identifier is reported only once > t.c:4: error: for each function it appears in.) > t.c:6: error: 'for' loop initial declaration used outside C99 mode > [rminnich@q tmp]$ > > > ron And the reason it doesn't is because in this code snippet, the variable i is undeclared. I assume since the i is not declared, the compiler steps out of C99 mode and refuses to allow the C99 construct of for (int i...) --Devon