Florian Report post Posted November 16, 2008 Hi, I have a problem with c ... I need actors.h in eye_candy_wrapper.h to have the actor struct available. On the other hand, I want to use ec_reference from eye_candy_wrapper.h in this actor struct, which is defined in actors.h. Including eye_candy_wrapper.h in actor.h does not work, of course. How can I resolve this circular dependency? Florian Share this post Link to post Share on other sites
LabRat Report post Posted November 16, 2008 Move the ec_reference to another file and #include that in both files with an #ifndef? That way whichever file gets included first defines it. A bit kludgy but what can you do? Share this post Link to post Share on other sites
Learner Report post Posted November 16, 2008 Hi, I have a problem with c ... I need actors.h in eye_candy_wrapper.h to have the actor struct available. On the other hand, I want to use ec_reference from eye_candy_wrapper.h in this actor struct, which is defined in actors.h. Including eye_candy_wrapper.h in actor.h does not work, of course. How can I resolve this circular dependency? Florian Why do you need the actor structure in that .h file? A pointer to that structure I could understand, but you don't want to be duplicating all the info there. Share this post Link to post Share on other sites
ago Report post Posted November 16, 2008 (edited) You can use an implicit struct declaration if you only need the reference. /* sample for eycandy_wrapper.h */ typedef struct { struct _actor * actor; } abc; /* sample for actors.h */ typedef struct _actor { ... } actor; Edited November 16, 2008 by ago Share this post Link to post Share on other sites
Alia Report post Posted November 17, 2008 Usually you do it this way: struct s; // declare structure struct s a; // declare variable of type struct s. Here you do not know what fields struct s has, and hence can't access them. struct s // definition of structure { ... } // Now you can access fields of struct s. Share this post Link to post Share on other sites
Florian Report post Posted November 18, 2008 Solved by moving the eye candy wrapper type defs to a new file. thanks for the quick answers! Share this post Link to post Share on other sites
LabRat Report post Posted November 18, 2008 \o/ I guessed right! where's my prize? Share this post Link to post Share on other sites