Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header File Doesn't Recognize typedef from a Different Header File

Tags:

c

eclipse

typedef

Right now I'm working on a project for my course on system programming. We were asked to program an apartment selling platform, with Realtors and Customers. I'm working on Eclipse.

Now, even though I didn't experience any problems like that in the past, one of my header files fails to recognize a typedef from a second header file.

Explanation: here are my files;

Realtor.h

#include "apartment.h"
#include "apartment_service.h"
#include "Report.h"
#include "Customer.h"
#include "mtm_ex2.h"


typedef struct realtor_t* Realtor;

While this is the second header file;

Customer.h

#include "Report.h"
#include "Realtor.h"
#include "apartment.h"
#include "apartment_service.h"
#include "mtm_ex2.h"

typedef struct customer_t* Customer;

MtmErrorCode purchaseApartment (Customer customer, Realtor realtor,
        ApartmentService service,
        int apartment_id);

MtmErrorCode makeOffer (Customer customer, Realtor realtor, ApartmentService
        service, int apartment_id, int new_price);

(the structs of customer_t and realtor_t are defined in the source files)

For some reason, the function declarations in Customer.h give me the following error: "unknown type name 'Realtor'". This is really weird because the same functions use other typedefs like 'ApartmentService' from "apartment_service.h".

like image 519
Iluha Bratan Avatar asked Oct 27 '25 08:10

Iluha Bratan


1 Answers

You are including Customer.h in Realtor.h.

This is where the error is occurring. In Realtor.h, the typedef for Realtor is not defined before Customer.h

Remove the inclusion of Customer.h from Realtor.h. That should solve the problem for the code given.

like image 85
Rishikesh Raje Avatar answered Oct 28 '25 22:10

Rishikesh Raje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!