【问题标题】:Why "Redefinition of typedef" error with GCC 4.3 but not GCC 4.6?为什么使用 GCC 4.3 而不是 GCC 4.6 出现“重新定义 typedef”错误?
【发布时间】:2011-09-25 11:04:10
【问题描述】:

我一直在使用 GCC 4.6 开发我的应用程序进行编译,但用户报告了“重新定义 typedef”错误。在我错误地告诉用户使用 Git 获取最新源的一些混乱之后,我仔细查看并发现了类似的内容:

/* 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 版本,这很容易修复,但为什么这不再是错误?还是需要报告?

【问题讨论】:

  • 不能...等...直到...我们用实际的...脚本语言...替换...C预处理器...例如PHP或客观的C smalltalk模拟...

标签: gcc compiler-errors typedef redefinition


【解决方案1】:

这看起来像deliberate change...

我手头没有 4.6,但如果您使用 -pedantic,您似乎会收到警告。

【讨论】:

    猜你喜欢
    • 2015-07-06
    • 2015-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    • 2020-04-16
    • 2010-10-17
    • 2014-09-14
    相关资源
    最近更新 更多