In Keil (MDK) variable definition position

Tip keil program is compiled: error: # 268: declaration may not appear after executable statement in block error,

He said that the statement can not be executed after the statement, that variable declaration written on the back using the statement, leading the program at compile-link,

Use this statement to a variable can not find this variable, it is wrong.

This is actually the standard adopted by the relevant keil, Keil5 (version 5,14.2) defaults to the C89 standard,

// given Code 
In Flag = 0 ; 
U16 I = 0 ;

This standard requires the variables included in the program can not function in the middle of the body, most can only begin to define or declare variables in a function. How to modify it?

method 1

The variables on the function very beginning, and pay attention to the order of the variables appear in the body of the function, or to declare variables should be defined in order to use the back, otherwise still reported the same mistake.

// modify the code 
U16 I = 0; 
In Flag = 0;

Method 2

The standard was changed keil C99, a recompile. As shown, the C99 Mode check option (middle right) at the option of the C / C ++ tab.

Method 3

Guess you like

Origin www.cnblogs.com/ys77/p/11541775.html