[Bug c/49182] New: Fordward declarations of struct not usable in function pointer types.

brad.lionberger at intel dot com gcc-bugzilla@gcc.gnu.org
Thu May 26 23:10:00 GMT 2011


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: unassigned@gcc.gnu.org
        ReportedBy: brad.lionberger@intel.com


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



More information about the Gcc-bugs mailing list