Sorry for such a basic question. I use the following code all the time:
Code:
for (int x=0;cond;expr) {
....
}
ie. The var x is initialised in the loop starter. A search on this board and comp.lang.c also shows thousands of instances of code like this.
However, when I do a lint check with this online lint checker:
http://www.cleanscape.net/products/l...ine/login.html
It gives me errors such as:
Code:
for (int sectionIndex = 0;sectionIndex < 3;sectionIndex++) {
^
mx.c: line 153: Error # 33: Expression expected.
---------------------------------------------------------------------
for (int sectionIndex = 0;sectionIndex < 3;sectionIndex++) {
^
mx.c: line 153: Warning # 102: Strange use of "for" statement.
> The statement in question is of a form which may reflect some
> sort of typing error; for example, the statement:
> for (i = 0; i < 10; j++) { ... }
> should be incrementing "i", not "j".
---------------------------------------------------------------------
for (int sectionIndex = 0;sectionIndex < 3;sectionIndex++) {
^
mx.c: line 153: Error # 26: ';' expected.
---------------------------------------------------------------------
for (int sectionIndex = 0;sectionIndex < 3;sectionIndex++) {
^
mx.c: line 153: Error # 21: Undefined symbol: sectionIndex
Is initialising a var like this not ansi or is this lint checker got problems. If it is not ansi, is there any compilers that do not support it?