9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Devon H. O'Dell" <devon.odell@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] A Plan 9 C request....
Date: Wed,  1 Mar 2006 20:52:43 -0800	[thread overview]
Message-ID: <9ab217670603012052t733f79f8m@mail.gmail.com> (raw)
In-Reply-To: <4405FD26.6080607@lanl.gov>

2006/3/1, Ronald G Minnich <rminnich@lanl.gov>:
> Brantley Coile wrote:
> >>now means
> >>
> >>      { int i; for(i=0; i<10; i++); }
> >
> >
> > Does that mean the following will compile?
> >
> > void
> > f(void)
> > {
> >       i = 3;
> >       put(i);
> >       for (int i = 0; i < 3; i++)
> >               put(i);
> >       if (i == 4) put(4);
> > }
> >
>
>   cat > t.c
> void
> f(void)
> {
>          i = 3;
>          put(i);
>          for (int i = 0; i < 3; i++)
>                  put(i);
>          if (i == 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


  reply	other threads:[~2006-03-02  4:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-01 17:56 Dan Cross
2006-03-01 18:09 ` Skip Tavakkolian
2006-03-01 18:15   ` Brantley Coile
2006-03-01 18:17   ` rog
2006-03-01 18:20   ` Russ Cox
2006-03-01 18:23     ` Brantley Coile
2006-03-01 18:32       ` Russ Cox
2006-03-01 18:32       ` jmk
2006-03-01 19:59       ` Ronald G Minnich
2006-03-02  4:52         ` Devon H. O'Dell [this message]
2006-03-01 18:31     ` Skip Tavakkolian
2006-03-02  4:27       ` David Leimbach
2006-03-02  4:37         ` Andrew R. Reiter
2006-03-02 11:44           ` Brantley Coile
2006-03-01 18:22   ` Richard Bilson
2006-03-02 12:07 Fco. J. Ballesteros
2006-03-02 12:14 ` Richard Miller
2006-03-02 12:25   ` Anthony Sorace
2006-03-02 12:26   ` Brantley Coile
2006-03-03 15:07     ` erik quanstrom
2006-03-04 10:00       ` Richard Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ab217670603012052t733f79f8m@mail.gmail.com \
    --to=devon.odell@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).