为什么“typedef的重定义”错误与GCC 4.3但不是GCC 4.6? [英] Why "Redefinition of typedef" error with GCC 4.3 but not GCC 4.6?
问题描述
我一直在使用GCC 4.6编译我的应用程序,但用户报告了重定义typedef错误。在一些混乱之后,我错误地告诉用户使用Git获取最新的源代码,我仔细看了一下,发现了类似这样的:
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;
这对于旧的GCC版本很容易修复,但为什么这不再是一个错误?
Which is quite easy to fix for the older GCC versions, but why is this no longer an error? Or does it need reporting?
推荐答案
这看起来像一个故意更改 ...
This looks like a deliberate change...
我没有4.6手,但如果您使用 -pedantic
,您会收到警告。
I don't have 4.6 to hand, but it looks like you will get the warning if you use -pedantic
.
这篇关于为什么“typedef的重定义”错误与GCC 4.3但不是GCC 4.6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!