Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: redefinition of typedef 'k_task_t' #120

Closed
ospanic opened this issue Mar 11, 2020 · 5 comments
Closed

error: redefinition of typedef 'k_task_t' #120

ospanic opened this issue Mar 11, 2020 · 5 comments

Comments

@ospanic
Copy link

ospanic commented Mar 11, 2020

我试图将tos移植到一块RISC-V架构的蓝牙开发板上,使用gcc 4.5.1进行编译,在编译第一个文件tos_completion.o就报如题错误,查看了一下源码,确实在tos_pend.h中有如下代码

typedef struct k_task_st k_task_t;

而在tos_task.h 文件中有这个结构体的具体定义

typedef struct k_task_st {
/************/
}k_task_t;

我用别的GCC编译器编译这些代码是没有问题的,但是使用我这个平台的GCC编译就报错。

我将tos_pend.h中的部分代码修改为如下形式

typedef struct k_task_st {
/************/
};

修改后可以编译通过。
目前还没有移植成功,请问我这样更改是不是会有其他问题?

@daishengdong
Copy link
Collaborator

这里因为前置声明的问题(tos_pend.h中使用到了k_task_t,但tos_task.h的包含在后面,所以在tos_pend.h中进行了前置声明),在有些其他编译器上也会报类型重定义的问题,但一般来说只是warning而不是error,你是否在gcc选项中开启了-Werror?

@ospanic
Copy link
Author

ospanic commented Mar 11, 2020

我检查了下,确定没有-Werror参数,请问按照我的方式修改代码会有潜在问题吗?

@daishengdong
Copy link
Collaborator

你的改法可以说的更具体一些么,你是在tos_pend.h里又定义了一遍k_task_st么

@daishengdong
Copy link
Collaborator

比较好的改法是,在tos_task.h中,将

typedef struct k_task_st {
... ...
} k_task_t;

改为:
struct k_task_st {
... ...
};

后面我多验证一下把这个改法上库。

@daishengdong
Copy link
Collaborator

上述改法已上库,可以拉取最新代码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants