I'm going trought this really quite long time and still don't see where could be the poblem.
Let's have header file Player.h
#ifndef PLAYER_H_
#define PLAYER_H_
typedef struct player
{
char *name;
int gameId;
int socketfd;
int points;
int state;
}player_struct;
#endif /* PLAYER_H_ */
And let's have second header file Game.h
#ifndef GAME_H_
#define GAME_H_
#include "Player.h"
#define NUMBEROFPLAYERS 2
typedef struct game
{
//Here
}game_struct;
#endif /* GAME_H_ */
The purpose of my typedef is to have a type player_struct using something like this:
It's source file Player.c - this works.
#include "Player.h"
player_struct *create_player
{
player_struct *player;
//body malloc ....
return player;
}
I use eclipse editor for C and C++, I have C project compiled with Linux GCC.
Why I'm not able to use type player_struct in header file game.h same way as in Player.C even if I have included the header file Player.h?
at place in header file game.h comented //HERE I want use
player_struct *players[NUMBEROFPLAYERS];
but it writes that dame type could not be resolved ..
Type 'player_struct' could not be resolved
I tryed many ways to write the struct and typedef but nothing helped. I really don't unerstand it any ideas? Thanks.
EDITED:
I was asked to put there all my code so:
problem is in header Game.h when i use type player_struct (it's first row).
first
/* Player.h */
#ifndef PLAYER_H_
#define PLAYER_H_
typedef struct player{
char *name; // player name
int gameId; // what game
int points; //how money points
int socketfd; //socket descriptor of player
int state;
} player_struct;
//create player
player_struct *create_player();
//delete player
void delete_player(player_struct *player);
#endif /* PLAYER_H_ */
second
/* Game.h */
#ifndef GAME_H_
#define GAME_H_
#include "Player.h"
//#include "Card.h"
#define PLAYERSLEN 2 // number of players
#define GAMESLEN 10 //number of games
#define CARDSLEN 64 //cards in one game
typedef struct game{
player_struct *players[PLAYERSLEN];//here is the problem
//card_struct *cards[CARDSLEN]; //her will be same problem
int active;
int playerOnTurn;
char *gameName;
int gameId;
}games_struct;
//typedef struct game game_struct;
//extern games_struct *games_array[GAMESLEN];
void init_game(games_struct *game);
void run_game(games_struct *game);
void *end_game(games_struct *game);
#endif /* GAME_H_ */