Why "Redefinition of typedef" error with GCC 4.3 but not GCC 4.6?
Asked Answered
S

1

6

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?

Snooker answered 29/6, 2011 at 19:44 Comment(1)
cant... wait... until... we replace... C preprocessor... with an actual... scripting language... like PHP or objective C smalltalk analog..Rather
G
6

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.

Gunyah answered 29/6, 2011 at 20:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.