ページ 11

2重インクルードについて

Posted: 2011年7月06日(水) 17:30
by かす
#include "DXLib.h"
#include "FMothershipPlayer.h"
#include "EnemyT.h"
#include "Field.h"

FMothership_t FMothership1[FM1_MAX];

とcppファイルでなっています。このcppにエラーが出てしまいます。
各ヘッダファイルにもポインタを使うため、ヘッダファイルが以下の様に使われています。

#include "FMothershipPlayer.h" → FMothership_tが定義されています。おそらくこれが複数回定義されています。
#include "EnemyT.h" → #include "EnemyPlayer.h"、#include"FMothershipPlayer.h"があります
#include "Field.h" → #include "EnemyPlayer.h"、#include "EshotPlayer.h"、"MothershipPlayer.h"、"MshotPlayer.h"、#include "FMothershipPlayer.h"があります。

このように#include "FMothershipPlayer.h" によって3重にFMothership_tが定義されてしまっているのですが、どのヘッダファイルにも
#ifndef
#define
#endif
2重インクルード防止をしています。にもかかわらず
     'FMothership_t' : 不明なオーバーライド指定子です
といったエラーがでます。試しに、#include "EnemyT.h" 、#include "Field.h"をとってみたらエラーは出ませんでした。
思うに2重インクルード防止がなされていないのだと思います。

どういった原因があるのかどなたか心当たりのある方、よろしくお願いします。

Re: 2重インクルードについて

Posted: 2011年7月06日(水) 18:13
by ISLe
Field.hの最後にある関数プロトタイプが;(コロン)で終わっていない、といったところでしょうか。

ex.
void foo() // ;が無い
FMothership_t FMothership1[FM1_MAX]; // error C3646: 'FMothership_t' : 不明なオーバーライド指定子です

Re: 2重インクルードについて

Posted: 2011年7月06日(水) 18:23
by かす
やばい、その通りでした

そんなことより、このわずかな情報でなんでわかったんですかね~凄すぎですよISLeさん
エスパーなんですね

くだらないことで質問してしまってすいませんでした。ありがとうございます!