declaration is incompatible with "void Timer_Init(void)"
时间: 2024-05-31 11:08:55 浏览: 15
This error message typically occurs when a variable declaration is made within a function that returns void. In C programming language, a function that returns void cannot have a return value, so any variable declared within the function will not be returned.
To fix this error, you need to move the variable declaration outside the function or change the function return type to a data type that matches the variable being declared.
相关问题
"error[pe147]: declaration is incompatible with \"__nounwind __softfp unsigned"
这个错误信息是在编译代码时遇到的错误,它表明某个声明与已有的类型不兼容。具体来说,错误信息中出现的“__nounwind __softfp unsigned”是一个类型修饰符。
首先,“__nounwind”是用于指示函数不会发生异常的修饰符。它表示被修饰的函数在运行过程中不会抛出任何异常。
其次,“__softfp”是用于指示函数采用软浮点的修饰符。软浮点是一种通过软件模拟实现的浮点运算,相对于硬件实现的浮点运算,软浮点通常效率较低。
最后,“unsigned”是用于指示无符号整数类型的修饰符。它表示该类型的数值范围不包含负数,只包含正数和零。
因此,根据错误信息,可以推断出声明与函数关联,而声明的类型与这些修饰符指示的类型不兼容。这意味着声明的某个类型修饰符可能不匹配函数的预期类型,可能是因为函数需要无符号整数类型,但声明的是有符号整数类型,或者函数期望使用软浮点运算,但声明的是硬浮点类型。
要解决这个错误,我们需要检查相关的声明,确保其类型修饰符与函数的预期类型相匹配。可以通过更改声明的类型或修饰符来解决该问题,以使其与函数的类型需求相符合。
..\SYSTEM\delay\delay.c(128): error: #147-D: declaration is incompatible with "void delay_init(u8)" (declared at line 21 of "..\SYSTEM\delay\delay.h")
根据你提供的错误信息,编译器报告了一个不兼容的声明错误。这个错误通常是因为你在定义函数时的参数类型与之前在头文件中声明的参数类型不匹配。
要解决这个问题,你需要检查函数的定义和头文件中的声明,并确保它们的参数类型一致。
在 delay.c 文件的第128行,编译器认为函数 `void delay_init(u8)` 的定义与之前在 delay.h 文件的第21行声明的 `void delay_init(u8)` 不兼容。这意味着这两个函数的参数类型不一致。
请检查这两个文件并确保它们的参数类型一致。如果需要,修改函数定义或声明,使它们一致。
例如,如果你的 delay.h 文件中有以下声明:
```c
void delay_init(u8 time);
```
那么在 delay.c 文件中的函数定义应该与之匹配:
```c
void delay_init(u8 time)
{
// 函数体
// ...
}
```
请仔细检查函数定义和声明,并确保它们的参数类型一致。如果你仍然遇到问题,请提供更多关于你的代码和错误信息的细节,以便我能够更好地帮助你解决问题。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)