编译包含下面代码的文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/*
* 函数名:Task_USART1
* 描述 : 任务创建函数
* 输入 :*p_arg
* 输出 : 无
*/
void
Task_USART1(
void
*p_arg)
{
(
void
)p_arg;
INT8U err;
INT8U *msg;
while
(1)
{
}
}
|
编译结果:
..\APP\app.c(51): error: #268: declaration may not appear after executable statement in block
分析问题:
这个错误的原因是对于变量的声明不能放在可执行语句后面,必须在主函数开头声明变量。在程序中声明一个变量时,需要在可执行语句之前声明,否则会出现以上错误。
更正:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/*
* 函数名:Task_USART1
* 描述 : 任务创建函数
* 输入 :*p_arg
* 输出 : 无
*/
void
Task_USART1(
void
*p_arg)
{
INT8U err;
INT8U *msg;
(
void
)p_arg;
while
(1)
{
}
}
|
在uCOS-II中(void)p_arg;
'p_arg' 并没有用到,防止编译器提示警告,应该放在变量声明之后。