解决警告C4133:’=’:不兼容的类型 – 从struct到struct
发布时间:2020-12-16 10:12:40 所属栏目:百科 来源:网络整理
导读:我的应用程序中有类似的结构. typedef struct _Test { int n; struct Test *Next; }Test;int main(int argc,char **argv){ Test tmp,tmp1; tmp.n = 1; tmp.Next = NULL; tmp1.n = 0; tmp1.Next = tmp; return 0;} 在线 tmp1.Next = tmp; 我收到以下警告消息
我的应用程序中有类似的结构.
typedef struct _Test { int n; struct Test *Next; }Test; int main(int argc,char **argv) { Test tmp,tmp1; tmp.n = 1; tmp.Next = NULL; tmp1.n = 0; tmp1.Next = &tmp; return 0; } 在线 tmp1.Next = &tmp; 我收到以下警告消息: 上面的代码有什么问题? 解决方法typedef struct _Test { int n; struct Test *Next; // --> struct Test is not a type here }Test; 它应该是 typedef struct _Test { int n; struct _Test *Next; // --> struct _Test is a type } Test; 因此,为了定义任何对象,它应该具有有效的数据类型,否则您将最终出错. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |