Arseniy Pavlov
Arseniy Pavlov

Reputation: 119

redeclared as different kind of symbol error

I have an .h file with the following declarations:

typedef SetElement (*copySetElements)(SetElement);
typedef void (*freeSetElements)(SetElement);
typedef int (*compareSetElements)(SetElement, SetElement);

and another .h file with the following delarations:

   SetElement copySetElements (SetElement element);
   void freeSetElements (SetElement element);
   int compareSetElements (SetElement element1, SetElement element2);

And I get the error: redeclared as different kind of symbol

in the second .h file (where I decalared the functions)

Once I change their names it dissapearrs. why?

Upvotes: 0

Views: 11256

Answers (1)

Klas Lindbäck
Klas Lindbäck

Reputation: 33273

Typedefs share the same namespace as functions and global variables.

When you use the same name for two different things, the compiler wouldn't know which one you mean. So it gives an error instead.

Upvotes: 2

Related Questions