是用Keil 5 打开的吗?
这是我在网上找的解决方法:
错误名称:declaration may not appear after executable statement in block. 变量声明不允许出现在语句之后, int main(void)
{
PLLCON = 1; // 这个(以及下面若干行)就是所谓的“executable statement ”
......
uint8 sec; // 这就是“declaration ”
这种在语句之后声明变量的方式,c++里面是正常的,现在的很多c编译器也允许。
但是最早的c是不许这么写的,要求所有的局部变量必须在函数开头声明,用的keil编译器也是这样要求的。 两种方法来解决这个问题 方法一:修改为正确语句 int main(void)
{ uint8 sec;
PLLCON = 1; // 这个(以及下面若干行)就是所谓的“executable statement ”
...... 方法二:设置keil 勾选C99 Mode
|