Code is something like this:
typedef struct _b_Node
{
//Identifier, will be an action
int id;
//Linked list infrastructure
struct _b_Node *next;
b_NodeList *connections;
//Data
float *probs;
} b_Node;
typedef struct _b_NodeList
{
b_Node *head;
b_Node *tail;
int size;
} b_NodeList;
typedef struct _b_Graph
{
b_NodeList * nodes;
} b_Graph;
Problem is that when the preprocessor goes to compile the header file, the list of pointers to nodes hasn't been defined yet. Where this problem could be avoided completely in an OOP language with inheritance, there's no way to order these. A solution might be using a void pointer to a list instead. I'm not entirely how efficient casting pointers is though, or how much extra work I'm going to have to do to ensure it is robust at the memory level.
// At the top:
ReplyDeletestruct _b_NodeList;
// inside _b_Node:
struct _b_NodeList *connections;
You can predeclare structs as long as you only need a pointer to them before the formal declaration. You could predeclare with the typedef, too, which is prettier.
Don't use a void pointer here, there's no need. Casting between pointer types is free, but it's just going to make the code unnecessarily ugly here.
--ryan.