Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

cross-refecence header file
Hi there! I've been struggling to find a solution to make a piece of code wo
rk. Basically I have a source structure and I've been asked to implement the
 functions. The problem is that there are two header files that cross-refere
nce each other and I have no clue about how to get this thing to compile:

code:
/*********** File clause.h ***********/ #ifndef CLAUSE_H_ #define CLAUSE_H_ #include "solver.h" struct clause { bool learnt; int size; float activity; lit *lits; }; typedef struct clause clause; extern bool new_clause(solver *s, bool appr, float act, vec_i *v, clause *c) ; #endif
code:
/***** clause.c *****/ #include "clause.h" bool new_clause(solver *s, bool appr, float act, vec_i *v, clause *c) { /* DO THE JOB ;-) */ }
code:
/***** solver.h ****/ #ifndef SOLVER_H_ #define SOLVER_H_ struct solver { int of_clauses; clause *listOfClauses; /* many other fields... */ }; extern int solver_addclause(solver *, clause *); #endif /* SOLVER_H_ */
code:
/****#include "solver.h" int solver_addclause(solver *, clause *) { /* DO THE JOB */ }
Of course, if I try to compile this structure I get error messages because s olver.h(which is pre-processed after clause.h) can't see the clause structur e(because of the #ifndef guards). Is there a way to make this thing compile correctly?

Report this thread to moderator Post Follow-up to this message
Old Post
scorpio2002
04-26-08 01:22 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Forum Jump:
All times are GMT. The time now is 10:36 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.