diff --git a/src/Back.h b/src/Back.h
index 184d4711..5c17614f 100644
--- a/src/Back.h
+++ b/src/Back.h
@@ -2,7 +2,11 @@
#include "WindowsWrapper.h"
-struct BACK
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct BACK
{
BOOL flag; // Basically unused
int partsW;
@@ -11,7 +15,7 @@ struct BACK
int numY;
int type;
int fx;
-};
+} BACK;
extern BACK gBack;
extern int gWaterY;
@@ -20,3 +24,7 @@ BOOL InitBack(const char *fName, int type);
void ActBack(void);
void PutBack(int fx, int fy);
void PutFront(int fx, int fy);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Boss.h b/src/Boss.h
index ab3e6807..8cf99182 100644
--- a/src/Boss.h
+++ b/src/Boss.h
@@ -2,6 +2,10 @@
#include "NpChar.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define BOSS_MAX 20
extern NPCHAR gBoss[BOSS_MAX];
@@ -14,3 +18,7 @@ void SetBossCharActNo(int a);
void HitBossBullet(void);
void ActBossChar(void);
void HitBossMap(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Caret.h b/src/Caret.h
index ab249e84..c7a33727 100644
--- a/src/Caret.h
+++ b/src/Caret.h
@@ -2,6 +2,10 @@
#include "WindowsWrapper.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct CARET_TABLE
{
int view_left;
@@ -30,3 +34,7 @@ void InitCaret(void);
void ActCaret(void);
void PutCaret(int fx, int fy);
void SetCaret(int x, int y, int code, int dir);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Flash.h b/src/Flash.h
index bbd99eaf..9d640a59 100644
--- a/src/Flash.h
+++ b/src/Flash.h
@@ -1,5 +1,9 @@
#pragma once
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void InitFlash(void);
void SetFlash(int x, int y, int mode);
void ActFlash_Explosion(int flx, int fly);
@@ -7,3 +11,7 @@ void ActFlash_Flash(void);
void ActFlash(int flx, int fly);
void PutFlash(void);
void ResetFlash(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Frame.h b/src/Frame.h
index 3f78684f..fa599399 100644
--- a/src/Frame.h
+++ b/src/Frame.h
@@ -1,6 +1,10 @@
#pragma once
-struct FRAME
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct FRAME
{
int x;
int y;
@@ -9,7 +13,7 @@ struct FRAME
int wait;
int quake;
int quake2;
-};
+} FRAME;
extern FRAME gFrame;
@@ -23,3 +27,7 @@ void SetFrameTargetBoss(int no, int wait);
void SetQuake(int time);
void SetQuake2(int time);
void ResetQuake(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Map.h b/src/Map.h
index 071999b9..44eb9e0b 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -2,6 +2,10 @@
#include "WindowsWrapper.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct MAP_DATA
{
unsigned char *data;
@@ -25,3 +29,7 @@ BOOL ChangeMapParts(int x, int y, unsigned char no);
void PutStage_Back(int fx, int fy);
void PutStage_Front(int fx, int fy);
void PutMapDataVector(int fx, int fy);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/MapName.h b/src/MapName.h
index c48312a8..15c7267a 100644
--- a/src/MapName.h
+++ b/src/MapName.h
@@ -2,7 +2,15 @@
#include "WindowsWrapper.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void ReadyMapName(const char *str);
void PutMapName(BOOL bMini);
void StartMapName(void);
void RestoreMapName(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/NpChar.h b/src/NpChar.h
index c5721561..9e03224d 100644
--- a/src/NpChar.h
+++ b/src/NpChar.h
@@ -5,6 +5,10 @@
#include "Draw.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define NPC_MAX 0x200
enum NPCCond
@@ -51,7 +55,7 @@ enum NPCNames
// To be continued
};
-struct NPCHAR
+typedef struct NPCHAR
{
unsigned char cond;
int flag;
@@ -98,8 +102,8 @@ struct NPCHAR
unsigned char shock;
int damage_view;
int damage;
- NPCHAR *pNpc;
-};
+ struct NPCHAR *pNpc;
+} NPCHAR;
struct EVENT
{
@@ -140,3 +144,7 @@ void GetNpCharPosition(int *x, int *y, int i);
BOOL IsNpCharCode(int code);
BOOL GetNpCharAlive(int code_event);
int CountAliveNpChar(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Organya.h b/src/Organya.h
index c81ca8a2..d8b820ff 100644
--- a/src/Organya.h
+++ b/src/Organya.h
@@ -1,4 +1,4 @@
- #pragma once
+#pragma once
#ifdef FIX_BUGS
// The original source code forgot to set this (you can tell because, in the original EXE,
@@ -9,6 +9,10 @@
#include "WindowsWrapper.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define MAXTRACK 16
#define MAXMELODY 8
#define MAXDRAM 8
@@ -27,3 +31,7 @@ void StopOrganyaMusic(void);
void SetOrganyaFadeout(void);
BOOL StartOrganya(LPDIRECTSOUND lpDS, const char *wave_filename);
void EndOrganya(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Stage.cpp b/src/Stage.cpp
index a9313d68..69046217 100644
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -248,9 +248,9 @@ const char *gMusicTable[42] = {
"WHITE"
};
+MusicID gMusicNo;
unsigned int gOldPos;
MusicID gOldNo;
-MusicID gMusicNo;
void ChangeMusic(MusicID no)
{
diff --git a/src/Stage.h b/src/Stage.h
index de2432d9..f5940025 100644
--- a/src/Stage.h
+++ b/src/Stage.h
@@ -2,7 +2,11 @@
#include "WindowsWrapper.h"
-enum MusicID
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum MusicID
{
MUS_SILENCE = 0x0,
MUS_MISCHIEVOUS_ROBOT = 0x1,
@@ -46,9 +50,9 @@ enum MusicID
MUS_SEAL_CHAMBER = 0x27,
MUS_TOROKOS_THEME = 0x28,
MUS_WHITE = 0x29
-};
+} MusicID;
-struct STAGE_TABLE
+typedef struct STAGE_TABLE
{
char parts[0x20];
char map[0x20];
@@ -58,7 +62,7 @@ struct STAGE_TABLE
char boss[0x20];
signed char boss_no;
char name[0x20];
-};
+} STAGE_TABLE;
extern int gStageNo;
extern MusicID gMusicNo;
@@ -66,3 +70,7 @@ extern MusicID gMusicNo;
BOOL TransferStage(int no, int w, int x, int y);
void ChangeMusic(MusicID no);
void ReCallMusic(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/TextScr.h b/src/TextScr.h
index fc46a1d0..a073b731 100644
--- a/src/TextScr.h
+++ b/src/TextScr.h
@@ -2,6 +2,10 @@
#include "WindowsWrapper.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct TEXT_SCRIPT
{
// Path (reload when exit teleporter menu/inventory)
@@ -64,3 +68,7 @@ void StopTextScript(void);
void PutTextScript(void);
int TextScriptProc(void);
void RestoreTextScript(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/vs2003/CSE2.vcproj b/vs2003/CSE2.vcproj
index 37a8cbe2..47797702 100644
--- a/vs2003/CSE2.vcproj
+++ b/vs2003/CSE2.vcproj
@@ -321,6 +321,12 @@
+
+
+