结构体定义在.h文件里 报conflicting types错

IranCyberArmy 2013-04-12 03:11:38
.h文件

typedef struct TT
{

} fileinfo;


void tttest(struct fileinfo*);



.c文件

#include "stc.h"

void tttest(struct fileinfo* fi)
{


}


gcc -c stc.c就报这个错
...全文
713 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
www_adintr_com 2013-04-12
  • 打赏
  • 举报
回复
www_adintr_com 2013-04-12
  • 打赏
  • 举报
回复
C 语言加了 typedef 也不需要 struct 了. C++ 没有加 typedef 都不需要 struct 的. 我试过了, 你试过了吗?
IranCyberArmy 2013-04-12
  • 打赏
  • 举报
回复
这么多人看不出来问题啊……总公司大牛了,C和C++语法还是区别很大的
IranCyberArmy 2013-04-12
  • 打赏
  • 举报
回复
引用 1 楼 adlay 的回复:
加了 typedef 就不用 struct 了吧. 把 struct fileinfo* 改成 fileinfo* 或 struct TT* 试试.
还有4楼的大哥,我发的是C语言区,C语言这样写才是标准,那样写更报错了. 你们可以自己用GCC试试,报错啊
aozhi 2013-04-12
  • 打赏
  • 举报
回复
去掉typedef也行。
IranCyberArmy 2013-04-12
  • 打赏
  • 举报
回复
In file included from stc.c:1:
stc.h:7: warning: \u2018struct fileinfo\u2019 declared inside parameter list
stc.h:7: warning: its scope is only this definition or declaration, which is probably not what you want
stc.c:3: error: conflicting types for \u2018tttest\u2019
stc.h:7: note: previous declaration of \u2018tttest\u2019 was here
vuqrzk5w 2013-04-12
  • 打赏
  • 举报
回复
定义端void tttest(struct fileinfo* fi) 不需要加struct
www_adintr_com 2013-04-12
  • 打赏
  • 举报
回复
加了 typedef 就不用 struct 了吧. 把 struct fileinfo* 改成 fileinfo* 或 struct TT* 试试.

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧