.\src\tm1668.c:43: error 146: two or more storage classes in declaration for 'delay_nms' .\src\tm1668.c:53: error 146: two or more storage classes in declaration for 'delay_us'
时间: 2023-06-27 08:03:56 浏览: 225
这个错误是因为在函数声明中同时使用了多个存储类别,比如在函数声明中同时使用了 static 和 extern 修饰符。这是不允许的,因为这些存储类别之间存在冲突。
你需要检查一下 tm1668.c 文件中的 delay_nms 和 delay_us 函数声明,看看是否同时使用了多个存储类别。如果是的话,你需要将其中一个存储类别去掉,只保留一个即可。例如,如果你想让这两个函数都是静态函数,那么可以将它们的声明改成:
```c
static void delay_nms(unsigned int n);
static void delay_us(unsigned int n);
```
如果你想让这两个函数都是外部可见的函数,那么可以将它们的声明改成:
```c
extern void delay_nms(unsigned int n);
extern void delay_us(unsigned int n);
```
如果你不确定该如何修改,可以将相关代码贴出来,我们再一起看看如何修改。
相关问题
kernel/defs.h:1:1: error: two or more data types in declaration specifiers 1 | struct buf; | ^~~~~~ kernel/defs.h:1:8: error: useless type name in empty declaration [-Werror] 1 | struct buf; | ^~~ kernel/defs.h:1:8: error: ‘inline’ in empty declaration
这些错误提示是由于在 `defs.h` 文件中的声明中存在问题导致的。
第一个错误提示 `error: two or more data types in declaration specifiers` 表示在声明中存在两个或更多的数据类型,这通常是由于语法错误导致的。请检查 `defs.h` 文件中的声明语句,确保只有一个有效的数据类型被声明。
第二个错误提示 `error: useless type name in empty declaration [-Werror]` 表示在空声明中存在无用的类型名称。这很可能是由于声明语句没有给出具体的类型或者声明语句本身是空的导致的。请检查 `defs.h` 文件中的声明语句,确保每个声明都有一个有效的类型。
第三个错误提示 `error: ‘inline’ in empty declaration` 表示在空声明中使用了 `inline` 关键字。`inline` 关键字用于指示编译器将函数体内的代码插入到函数调用的地方,但是在空声明中使用是没有意义的。请检查 `defs.h` 文件中的声明语句,确保不在空声明中使用 `inline` 关键字。
检查并修复这些问题后,重新编译代码应该就可以解决这些错误了。
../Core/Inc/main.h:55:23: error: two or more data types in declaration specifiers typedef unsigned char _Bool;
这 error 的原因是 `_Bool` 是 C99 中的关键字,但在某些编译器中,可能已经定义了 `_Bool` 作为其他类型的别名。因此,您可以尝试使用 `<stdbool.h>` 头文件来定义布尔类型,而不是使用 `_Bool`。
要使用 `<stdbool.h>` 头文件,请在代码中添加以下行:
```
#include <stdbool.h>
```
然后,您可以使用 `bool` 代替 `_Bool`:
```
typedef bool my_bool;
```
或者,您也可以使用 `#define` 来定义布尔类型:
```
#define my_bool unsigned char
```
请注意,这种方法可能会导致一些编译器警告或错误,因为它不是标准的布尔类型定义方式。
阅读全文
相关推荐

















