Declaring variables inside the for loop statement

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Declaring variables inside the for loop statement

1,851 次查看
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

标签 (1)
0 项奖励
回复
1 回复

1,549 次查看
matthewkendall
Contributor V

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

0 项奖励
回复