2017-05-02 4 views
0

に書かれている一方で、構造体のtypedefを持つ1つのHファイルには、私は次のエラーを受信して​​います:前に指定-修飾子リストを期待- そのフィールドが他の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内で以下のように書くべきだった

+1

ネストすることはできません 'typedef'ような、私の知る限り。あなたは確かにはいけません。また、 'challenge_system.h'には' challenge_room_system_fields.h'が含まれ、 'challenge_room_systems_fields.h'には' challenge_system.h'が含まれています。複数の包含保護が表示されていないので、状況がひどく難しくなります。思考とコードを再編成する必要があります。 –

+0

ようこそStackOverflowへ。 [ツアー]を取ってください。 よくある質問stackoverflow.com/help/how-to-ask、 [mcve]を作成してください。 見積もりは完了していますか?私は、どこかの補充警備員が存在すべきだという気持ちがある。 – Yunnosch

答えて

0

....のみ、事前に

感謝をchallenge_room_system_fields.h変更させて頂いております:

char* system_name; 
    struct Challenge* challenges; 
    int numOfChallenges; 
    struct ChallengeRoom* rooms; 
    int numOfRooms; 
    int timeOfLastAction; 

理由は#ということです定義によって含めるには、次のようにchallenge_system.hが見えますので、最終的には...

が含まれたファイルとコピー・ペースト、それの代わりに私が書いたの#include行のをとります。

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; 

そして今、それは動作します:)

関連する問題