expected specifier-qualifier-list before 'typedef' - 一个 H 文件,其类型定义为结构,而其字段写入另一个 H

expected specifier-qualifier-list before 'typedef' - one H file with a typedef of a struct while its fields are written in another H

我收到下一个错误:

'typedef' 之前的预期说明符限定符列表( 在 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

提前致谢....

我应该在 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;

现在可以了:)