我收到了下一个错误:
在' typedef'之前的预期说明符 - 限定符列表( in challenge_room_system_fields.h ):
这是challenge_system.h:
typedef struct SChallengeRoomSystem
{
#include "challenge_room_system_fields.h"
} ChallengeRoomSystem;
这是challenge_room_system_fields.h:
#include "challenge_system.h"
typedef struct SChallengeRoomSystem //this is where i get the error
{
char* system_name;
struct Challenge* challenges;
int numOfChallenges;
struct ChallengeRoom* rooms;
int numOfRooms;
int timeOfLastAction;
} ChallengeRoomSystem;
有人可以帮我找出错误吗?
我知道这不是处理结构的最佳方法,但作为一项学校作业,我不需要更改challenge_system.h。我被允许只更改challenge_room_system_fields.h
提前致谢....
答案 0 :(得分:0)
我应该在challenge_room_system_fields.h中写下以下内容:
char* system_name;
struct Challenge* challenges;
int numOfChallenges;
struct ChallengeRoom* rooms;
int numOfRooms;
int timeOfLastAction;
原因是#include定义采用包含文件并复制粘贴它而不是我写的行#include ...
所以最终challenge_system.h看起来如下:
typedef struct SChallengeRoomSystem
{
// this is where previously i had: #include "challenge_room_system_fields.h"
//now i will have the following:
char* system_name;
struct Challenge* challenges;
int numOfChallenges;
struct ChallengeRoom* rooms;
int numOfRooms;
int timeOfLastAction;
} ChallengeRoomSystem;
现在它有效:)