Silly Q about circular references
Hello,
I have a silly question about circular references in C (note: not C++):
typedef void ( *FSM ) ( CALL_CB* );
typedef struct _fsm_cb
{
FSM fsm_entry;
} FSM_CB;
typedef struct _call_cb
{
FSM_CB *fsm;
} CALL_CB;
int main()
{
CALL_CB* call_cb;
return 1;
} This can't compile because FSM_CB is referencing CALL_CB and vice versa:
test.c:4: syntax error before '*' token
I know that C++ has a solution to this, by simply declaring the second class before the first:
class Second;
class First
{
Second* m_second;
};
class Second
{
First* m_first;
};
main ()
{
First* aFirst;
Second* aSecond;
}
Can anyone help?
Thanks,
Paul