vendredi 29 mai 2015

Unkown type name "Enemy" error after including all headers in C

I'm developing a game with SDL 2.0 in C and I have the following problem: After including all the needed .h files on each file, the compiler shows an error (unknown type name 'Enemy') on shoots.h, where I have a function with a parameter of type Enemy declared on enemy.h.

The header files where I think I'm getting the error are bullet.h, enemy.h, mobs.h, and shoots.h. (There are more like sdl.h)

bullet.h

#ifndef BULLET_H_INCLUDED
#define BULLET_H_INCLUDED
#include "sdl.h"

typedef struct Bullet *Bullet;

#endif // BULLET_H_INCLUDED

enemy.h

#ifndef ENEMY_H_INCLUDED
#define ENEMY_H_INCLUDED
#include "sdl.h"
#include "shoots.h"

typedef struct Enemy *Enemy;

#endif // ENEMY_H_INCLUDED

mobs.h

#ifndef MOBS_H_INCLUDED
#define MOBS_H_INCLUDED
#include "enemy.h"

typedef struct EnemyList *EnemyList;
typedef struct EnemyPosition *EnemyPosition;

#endif // MOBS_H_INCLUDED

shoots.h

#ifndef SHOOTS_H_INCLUDED
#define SHOOTS_H_INCLUDED
#include "sdl.h"
#include "player.h"
#include "bullet.h"
#include "enemy.h"


typedef struct BulletList *BulletList;
typedef struct BulletPosition *BulletPosition;

void initEnemyShoots(BulletList l, BulletPosition p, Player pl, Enemy e);

#endif // SHOOTS_H_INCLUDED

struct Enemy declaration on enemy.c

struct Enemy {
    SDL_Surface *sprite;    //Enemy sprite
    int x, y;             //Enemy position
    int w, h;               //Enemy hitbox
    BulletList ammo;      //Enemy bullets
};

Those headers also have the declaration of functions implemented on each .c file. All structs are defined on his own .c

That initEnemyShoots is where I have the problem, since one of it's parameters is type Enemy. How can I solve that?

Aucun commentaire:

Enregistrer un commentaire