From: Jesse Ruffin <jesse@ajp-services.net>
To: linux-c-programming@vger.kernel.org
Subject: Re: Code critique: checking for syntax errors
Date: Mon, 23 Jan 2006 19:44:35 -0500 [thread overview]
Message-ID: <43D57873.10005@ajp-services.net> (raw)
In-Reply-To: <43D55FEB.2070909@colannino.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
James Colannino wrote:
|
| What's weird about that is that in order to do variable declarations
| within the definition of a for loop, I need to pass -std=c99 to GCC.
| However, I don't need to do that in order to simply declare variables
| later in the function. That would lead me to believe that C99 is not
| required to do so. Could it possibly be a C89 thing? How far back is
| considered ANSI C?
|
The gcc compiler by default uses -std=gnu89, which is C89 (which is the
ANSI/ISO standard) plus extensions. One of them is this:
| ISO C99 and ISO C++ allow declarations and code to be freely mixed
| within compound statements. As an extension, GCC also allows this in
| C89 mode. For example, you could do:
|
| int i;
| /* ... */
| i++;
| int j = i + 2;
However, this does not extend to variables in loop declarations. C99
does allow declarations in loops, but C89 requires declarations with
constant expressions only before any evaluated expression.
If you want to see gcc do ANSI c, try:
gcc -Wall -ansi -pedantic
The pedantic is necessary to get some extra warnings about ANSI issues.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFD1Xhz8GGeAXLl3osRAsQ6AKCJcs/9ozAQvbCJ/YLd2ZHbLiA1CQCfcjxm
XWnVeMnOw5Z6OREybtXpZpE=
=3zmi
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2006-01-24 0:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-21 19:10 Code critique: checking for syntax errors James Colannino
2006-01-22 9:34 ` Jesse Ruffin
2006-01-23 19:47 ` James Colannino
2006-01-23 22:37 ` Jesse Ruffin
2006-01-23 22:59 ` James Colannino
2006-01-24 0:44 ` Jesse Ruffin [this message]
2006-01-24 2:06 ` James Colannino
2006-01-24 9:34 ` Glynn Clements
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=43D57873.10005@ajp-services.net \
--to=jesse@ajp-services.net \
--cc=linux-c-programming@vger.kernel.org \
/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).