I think my errors and code will explain the issue fairly well (my thoughts at the bottom):
When I compile:
Code:
In file included from mylib/physics.h:21,
from mylib/level.h:26,
from mylib/gameload.h:14,
from mylib/game.h:17,
from mylib.h:4,
from main.c:13:
mylib/gameupdate.h:46: error: parse error before '*' token
In file included from mylib/physics.h:21,
from mylib/level.h:26,
from mylib/level.c:14:
mylib/gameupdate.h:46: error: parse error before '*' token
In file included from mylib/physics.h:21,
from mylib/level.h:26,
from mylib/gameload.h:14,
from mylib/gameload.c:14:
mylib/gameupdate.h:46: error: parse error before '*' token
In file included from mylib/physics.h:21,
from mylib/level.h:26,
from mylib/gamedraw.h:24,
from mylib/gamedraw.c:14:
mylib/gameupdate.h:46: error: parse error before '*' token
In file included from mylib/physics.h:21,
from mylib/level.h:26,
from mylib/gameload.h:14,
from mylib/game.h:17,
from mylib/game.c:14:
mylib/gameupdate.h:46: error: parse error before '*' token
The offending code from gameupdate.h
Code:
#ifndef GAMEUPDATE_H
#define GAMEUPDATE_H
#include <stdio.h>
#include <time.h>
#include "level.h" /* <-- Level header included here! */
#include "gameobj.h"
#include "entity.h"
#include "worldgeo.h"
#include "graphics.h"
#include "bool.h"
#include "artasset.h"
#include "physics.h"
#include "linklist_go.h"
#include "linklist_aa.h"
#include "gameState.h"
#include "custmath.h"
...
void Update(Level *level, /* <-- Errors are from here! */
gameState *currentState,
LinkedList_GO *layers,
bool changeTracker[SCREEN_HEIGHT][SCREEN_WIDTH],
Entity* player);
...
#endif
Definition of Level in level.h
Code:
#ifndef LEVEL_H
#define LEVEL_H
#include "gameobj.h"
#include "entity.h"
#include "worldgeo.h"
#include "graphics.h"
#include "bool.h"
#include "artasset.h"
#include "physics.h"
#include "linklist_go.h"
#include "linklist_aa.h"
#include "gameState.h"
#include "custmath.h"
...
typedef struct Level /* <-- Definition here! */
{
char name[32];
/*
Layers:
0 - Background (Map)
1 - Geometry
2 - Entities
3 - HUD
*/
LinkedList_GO layers[4];
LinkedList_AA artBank;
Entity player;
WorldGeometry map;
} Level;
...
#endif
From my understanding this parse error would indicate that the compiler doesn't know what "Level" is when it reaches the line where the error is. Does it matter that I have "level.h" including "gameupdate.h" and "gameupdate.h" including "level.h"? If so - how could I resolve this (I have need to use level in gameupdate, and I have one function in gameupdate that level needs), if not - any ideas? I'm stumped ...
Thanks a ton in advance for your time and assistance!
EDIT: I forgot to mention - all my files except main.c are in a folder named mylib in the same directory as main.c.