tags:

views:

81

answers:

1

I'm trying to integrate an existing library into my project. But I keep getting this "Redefinition typedef error" when I try to compile. Here's the code that's part of the library.

Code:

typedef struct _tagAbc Abc;
typedef void *Apple (Abc* Orange);

typedef struct _tagAbc
{
    Apple red;
}
Abc;

It seems that the compiler doesn't like the pre-declared struct and the actual definition of the struct together. Is there anywhere to fix this problem?

+7  A: 

The code is trying to typedef struct _tagAbc twice, once in the first line and once in the actual structure declaration. If you modify the structure declaration as shown below it should work correctly.

typedef struct _tagAbc Abc;
typedef void *Apple (Abc* Orange);

struct _tagAbc
{
    Apple red;
};
rzrgenesys187