Re: Error: 'for' loop initial declaration used outside c99 mode
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 03 Nov 2006 05:55:20 GMT
"Pedro Pinto" <kubic62@xxxxxxxxx> writes:
When compiling my program i got this error:
Error: 'for' loop initial declaration used outside c99 mode
What is it and how can i solve it?
It's an error message about some code that you failed to show us. In
general, you can't expect us to know what the problem is unless you
show us the actual code as well as the error message.
In this case, you've lucked out. You probably have something like this:
...
for (int i = 0; i < N; i ++) {
...
}
...
which declares the loop variable as part of the for loop itself. This
feature was added to the language with the C99 standard; it's not
supported in C90.
You can either use C99 mode (but beware: gcc doesn't fully support
C99; see <http://gcc.gnu.org/c99status.html>), or you can re-write
the code to be compatible with C90:
...
int i;
...
for (i = 0; i < N; i ++) {
...
}
...
which is legal C99 as well.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- Error: 'for' loop initial declaration used outside c99 mode
- From: Pedro Pinto
- Error: 'for' loop initial declaration used outside c99 mode
- Prev by Date: Re: Which C tool?
- Next by Date: Re: character byte str[i] treated as signed, I need unsigned
- Previous by thread: Error: 'for' loop initial declaration used outside c99 mode
- Next by thread: Re: Error: 'for' loop initial declaration used outside c99 mode
- Index(es):
Relevant Pages
|
|