Why “Redefinition of typedef” error with GCC 4.3 but not GCC 4.6?

风格不统一 提交于 2019-12-10 14:18:32

问题


I've been developing my application using GCC 4.6 for compilation but a user reported the "redefinition of typedef" error. After some confusion where I wrongfully told the user to fetch the latest source using Git, I took a closer look and found something similar to this:

/* mystruct.h */

#ifdef MYSTRUCT_H
#define MYSTRUCT_H

typedef struct _mystruct mystruct

#endif



/* mystruct.c */
#include "mystruct.h"

typedef struct _mystruct
{
    int a;
    int b;

} mystruct;

Which is quite easy to fix for the older GCC versions, but why is this no longer an error? Or does it need reporting?


回答1:


This looks like a deliberate change...

I don't have 4.6 to hand, but it looks like you will get the warning if you use -pedantic.



来源:https://stackoverflow.com/questions/6526322/why-redefinition-of-typedef-error-with-gcc-4-3-but-not-gcc-4-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!