http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49182
Summary: Fordward declarations of struct not usable in function
pointer types.
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
A forward declaration of a struct to be used in a function pointer type
definition confuses the compiler. The following code does not compile using
gcc but will with two other compilers.
// Forward declaration
typedef struct _a a;
// Pointer to function with struct as parameter
typedef int (*FxnPointer)(a* WontComplie);
// Actual declaration of struct with function pointer type declared above.
typedef struct _a
{
int foo;
int bar;
FxnPointer PtrToFxn;
} a;
int main(void)
{
a test_struct;
return 0;
}
Errors returned are as follows:
FxnPtrEx.c:13:3: error: redefinition of typedef ‘a’
FxnPtrEx.c:2:19: note: previous declaration of ‘a’ was here