typedef errors in binary tree example program

mkwan

Tech
greetings,

I am trying to compile a binary tree application source code and I am getting compiler errors stated below:

[localhost(iBook):cnt252/examples/BTree] mkwan% c++ -g main.cpp BTree.cpp -o binary
In file included from main.cpp:1:
BTree.h:32: `typedef struct Node * pNode' redeclared as different kind of symbol
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/AE.framework/Headers/AERegistry.h:917: previous declaration of `enum {anonymous} pNode'
In file included from BTree.cpp:10:
BTree.h:32: `typedef struct Node * pNode' redeclared as different kind of symbol
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/AE.framework/Headers/AERegistry.h:917: previous declaration of `enum {anonymous} pNode'
[localhost(iBook):cnt252/examples/BTree] mkwan%


this is part of the source code below:

struct Node
{
Node *pL_child;
Node *pR_child;
int iData;

Node(void)
{
pL_child = 0;
pR_child = 0;
}
};

typedef Node* pNode;
.
.
.

and yet I get no compiler errors in visual c++ program...can anyone help me?

I don't know if I made my question clear enough...I apologize for that

mkwan
 
Hi mkwan,
it's clashing with an enum defined in the AE Interfaces (that is pNode).
Either you change that pNode with a better name or you include it inside a namespace (if yor using c++). No wonder it works with vc++: there is no AERegistry.h in windows.

i.e.:

...
typedef Node * MyNodePtr; // or just another name

or (for c++):

namespace MyNamespace
{
...
typedef Node * pNode;
}

(you refer to it with MyNamespace::pNode)

Or even better, do you really need framework ApplicationServices?, if not get rid of it, and it should work as it is. :D

...I just hate those silly-public-unprefixed declarations...
 
Back
Top