Declaring variables inside the for loop statement

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Declaring variables inside the for loop statement

1,109 Views
HeMyFAE
NXP Employee
NXP Employee

DEar CW,


Declaring variables inside the for loop statement:

 

for(uint8_t Chr = 0; Chr < ITEM_TEXT_LENGTH; Chr++)

 

Versus not:

 

uint8_t Chr;

for(Chr = 0; Chr < ITEM_TEXT_LENGTH; Chr++)

 

Declaring variables inside the for loop statement throws this error:

 

‘for’ loop initial declarations are only allowed in C99 mode

It certainly isn’t a problem to move the declarations outside of the for loop, but I’d like to have the option of using C99 or know where it is. Do you  know if there is a checkbox or command line switch for GCC somewhere?

 

Regards,

hy

Labels (1)
0 Kudos
1 Reply

807 Views
matthewkendall
Contributor V

Right-click on project | Properties | C/C++ Build | Settings | Tool Settings tab | ARM Ltd Windows GCC Compiler | Miscellaneous | Language Standard.

0 Kudos