#43: FILE: test/test_timer.c:143: + static int init = 0;$ ERROR: do not initialise statics to 0
时间: 2024-03-29 20:40:09 浏览: 78
The error message is telling you not to initialize static variables to 0 explicitly. In C, static variables are implicitly initialized to 0, so there is no need to explicitly set them to 0.
To fix the error, you can simply remove the initialization of the static variable `init` to 0, and let the variable be implicitly initialized to 0. For example:
```
static int init;
```
This will ensure that the static variable is correctly initialized to 0, and avoid the error message.
相关问题
..\HARDWARE\TIMER\timer.c(225): error: #268: declaration may not appear after executable statement in block
这个错误提示是因为在函数块内部,在已经有可执行语句的情况下,出现了变量或者函数的声明语句。
比如下面这段代码就会出现这个错误:
```
void test() {
printf("hello world");
int a = 10; // 这里出现了变量声明语句
}
```
解决方法是把变量或函数的声明语句放到函数块的开头,如下所示:
```
void test() {
int a = 10; // 把变量声明语句放到函数块开头
printf("hello world");
}
```
这样就可以解决这个错误了。
阅读全文