1 Attachment(s)
Circular Dependency error
Hi ,
I was doing Uni assignment ( not looking for a full solution ) had to use the start up code provided ( other wise this issue would not have come ),
when compiling the source I get the following error
"pms_program.h:54:56: error: expected declaration specifiers or ‘...’ before ‘CourseType’"
the code you are looking for in pms_course.h ( there is a circular dependency between pms.h , pms_course.h and pms_program.h)
Head tutor provided a GUARD however don't think it works properly
function prototype AppendProgram ( part of doubly linked list )
I have attached the full course code.
As much as I like I cannot change the structure of the startup code , I was hoping that someone know a solution or cam point me to the problem
please see attached zip file for the entire source code.
Thanks for Stopping by.
Re: Circular Dependency error
I'm not too keen to uncompress that and look through all the possible files, so I'll just say this: sketch out the dependencies. What headers are included where? Do you define a class such that it requires the definition of another class that requires its definition?
Re: Circular Dependency error
Quote:
Originally Posted by
aamir121a
Hi ,
I was doing Uni assignment ( not looking for a full solution ) had to use the start up code provided ( other wise this issue would not have come ),
when compiling the source I get the following error
"pms_program.h:54:56: error: expected declaration specifiers or ‘...’ before ‘CourseType’"
the code you are looking for in pms_course.h ( there is a circular dependency between pms.h , pms_course.h and pms_program.h)
Head tutor provided a GUARD however don't think it works properly
How is this supposed to work (from pms.h)?
Code:
/* program header files */
#include "pms_program.h"
#include "pms_course.h"
#ifndef PMS_H
#define PMS_H
This is a non-starter right there.
Secondly, there is no way to fix the problem of circular dependency unless you change the code.
Regards,
Paul McKenzie
Re: Circular Dependency error
this is strictly a c code ( so no classes ) problem comes from the fact pms.h in included in pms_courses.h and pms_program.h and the are included in pms.h . ( hence the circular dependency )
please also look at the typdef in pms.h
Code:
/* predeclare the program and course structs */
typedef struct program* ProgramTypePtr;
typedef struct course* CourseTypePtr;
using them seems to solve the problem , however I do not understand why , perhaps an explanation will help me in the future.
Re: Circular Dependency error
Quote:
Originally Posted by aamir121a
this is strictly a c code ( so no classes )
The same applies to structs.
Quote:
Originally Posted by aamir121a
using them seems to solve the problem , however I do not understand why
It is probably because you are then not including the headers but using forward declarations instead.
Re: Circular Dependency error
The .c file that doesn't compile is pms_course.c. To enable this to compile, the following change should be made
Code:
/*#include "pms_course.h"*/
#include "pms.h"
The other .c modules compile with only a couple of warnings.
Re: Circular Dependency error
Thank you all for posting