Code Comments
Programming Forum and web based access to our favorite programming groups.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) ; #endifcode:
/***** 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_ */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?code:
/****#include "solver.h" int solver_addclause(solver *, clause *) { /* DO THE JOB */ }
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.