I’ve already gone through a bunch of threads on hear and a bunch of others I found on Google. I still can’t seem to get this right.
//Room.h
#ifndef ROOM_H
#define ROOM_H
#include "Door.h"
typedef struct {
Door* doors[3];
} Room;
#endif
//Door.h
#ifndef DOOR_H
#define DOOR_H
#include "Room.h"
typedef struct {
Room* room1;
Room* room2;
} Door;
//main.c
#include <stdio.h>
#include "Room.h"
int main() { ... }
I already tried adding this to the top of Door.h
typedef struct Room room1;
//typedef struct Room* room1;
//typedef stuct Room;
//typedef struct Room*;
All gave me this error:
“unknown type name ‘Room’”
I want to keep these structs separate header files.
C-way of struct reference:
room.h
door.h