Declaring variables inside the for loop statement

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Declaring variables inside the for loop statement

1,836件の閲覧回数
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,534件の閲覧回数
matthewkendall
Contributor V

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

0 件の賞賛
返信