Keil MDK 嵌入式开发问题:declaration may not appear after executable statement in block
Keil MDK 嵌入式开发问题:declaration may not appear after executable statement in block
·
- 在使用 Keil MDK 开发项目,编译时,报如下错误
*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
Build target 'led_breathe'
compiling main.c...
user\main.c(11): error: #268: declaration may not appear after executable statement in block
uint8_t dutyCycle = 0;
user\main.c(12): error: #268: declaration may not appear after executable statement in block
uint8_t dir = 0;
user\main.c: 0 warnings, 2 errors
".\Objects\led_breathe.axf" - 2 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:00
# 关键错误
user\main.c(11): error: #268: declaration may not appear after executable statement in block
uint8_t dutyCycle = 0;
user\main.c(12): error: #268: declaration may not appear after executable statement in block
uint8_t dir = 0;
问题原因
- 这个错误是变量声明放在了可执行代码之后(见下例),C89 标准不允许混合声明和代码
int main()
{
TIM3_init();
TIM3_start();
uint8_t dutyCycle = 0;
uint8_t dir = 0;
...
}
处理策略
- 在 Keil MDK 中启用 C99

更多推荐
所有评论(0)