まず矩形を作るためのRECT構造体を作り、
#ifndef DEF_RECT_H
#define DEF_RECT_H
typedef struct{
int left;
int top;
int right;
int bottom;
}RECT;
int makeRect(int x,int y,int w,int h);
bool checkRect(RECT rect1,RECT rect2);
#endif#include "DxLib.h"
#include "RECT.h"
int makeRect(int x,int y,int w,int h){
RECT *to;
to->left=x;
to->top=y;
to->right=x+w;
to->bottom=y+h;
return (to);
}
bool checkRect(RECT rect1,RECT rect2){
if(rect1.right < rect2.left)return false;
if(rect2.right < rect1.left)return false;
if(rect1.bottom < rect2.top )return false;
if(rect2.bottom < rect1.top )return false;
return true;
}
1>------ ビルド開始: プロジェクト: action, 構成: Debug Win32 ------
1>コンパイルしています...
1>RECT.cpp
1>c:\users\shun\desktop\action\rect.h(9) : error C2371: 'RECT' : 再定義されています。異なる基本型です。
1> c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(324) : 'RECT' の宣言を確認してください。
1>c:\users\shun\desktop\action\rect.cpp(10) : error C2440: 'return' : 'RECT *' から 'int' に変換できません。
1> この変換が可能なコンテキストはありません。
1>ビルドログは "file://c:\Users\shun\Desktop\action\Debug\BuildLog.htm" に保存されました。
1>action - エラー 2、警告 0
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
ifndefで囲んでいるのになぜ再定義とみなされるのか。
アドバイスお願いします。