从另一个头文件中的一个头文件构造

这段时间我已经很长时间了,但仍然没有看到哪里可能是个问题。

我们有头文件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_ */ 

让我们有第二个头文件Game.h

 #ifndef GAME_H_ #define GAME_H_ #include "Player.h" #define NUMBEROFPLAYERS 2 typedef struct game { //Here }game_struct; #endif /* GAME_H_ */ 

我的typedef的目的是使用类似这样的类型:player_struct:

这是源文件Player.c – 这是有效的。

 #include "Player.h" player_struct *create_player { player_struct *player; //body malloc .... return player; } 

我使用eclipse编辑器进行C和C ++编写,我使用Linux GCC编译了C项目。

为什么我不能在头文件game.h中使用类型player_struct,就像在Player.C中一样,即使我已经包含头文件Player.h?

在头文件game.h中的位置注释//这里我想用

 player_struct *players[NUMBEROFPLAYERS]; 

但它写道,dame类型无法解决..

无法解析类型’player_struct’

我尝试了很多方法来编写struct和typedef,但没有任何帮助。 我真的不赞成任何想法吗? 谢谢。

编辑:我被要求将所有代码放在那里:当我使用类型player_struct(它的第一行)时,问题出现在标题Game.h中。
第一

  /* 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_ */ 

第二

  /* 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_ */ 

尝试在不使用typedef的情况下定义它们。