struct - C typedef confliction -
so attempting construct b-tree, using 2 types of nodes, individual key nodes (knode) , super node containing number of knodes based on order size (sibnode). problem keep running set work need knode pointers in sibnode (ex. pkey , smallestpnt) sibnode pointers in knode (ex. nxtkey , child). whichever typedef put first returns error unknown type pointers (example in order returns: error: unknown type name 'knode'). if give me advice on how avoid error appreciated.
typedef int keyt; //b-tree node typdef typedef struct { int size; int cursor; knode* pkey; knode* smallestpnt; }sibnode; //key node typedef typedef struct { keyt* key; sibnode* nxtkey; sibnode* child; }knode;
when sibnode
type defined, type knode
hasn't been defined yet.
use forward declaration this:
struct knode; //this forward declaration typedef struct { int size; int cursor; struct knode* pkey; //here struct knode* smallestpnt; //here }sibnode; typedef struct knode //and here { keyt* key; sibnode* nxtkey; sibnode* child; }knode;
Comments
Post a Comment