您的位置:首页 > 移动开发

#268: declaration may not appear after executable statement in block

2018-01-05 14:33 2271 查看

使用MDK调试程序的时候,出现了以下错误:

#268: declaration may not appear after executable statement in block

错误原因

keil官网解释:

Keil C compilers are based on ANSI C C90 standard, but are expanded with added language extensions, practical concessions to the architectural peculiarities of the microcontrollers, and other features that meet the needs of embedded systems programmers.

In C90, all variable declarations must happen before any executable statements in a function or other code block. The compiler error message mentions the line number of the offending line of code.

简单讲就是C90的原因

解决方法

C99 enables you to mix declarations and statements within compound statements, like in C++. Turn on C99 mode in the Keil IDE under Project → Options for Target → C/C++ tab, and check C99 Mode. Read more about the –c99 compiler switch here.

即,将MDK里的C语言标准改为C99
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言 MDK
相关文章推荐