Browse Source

Use 'extern "C"' only when necessary

Only function & variable declarations should be put inside the 'extern
"C"' region. Header includes, macro & type definitions should be moved
outside, or some C++ function declared inside outter headers may break.

Three new macros are defined:
PAL_C_LINKAGE        ---- Use this if you want to declare one var/func
PAL_C_LINKAGE_BEGIN  ---- Use this at the begin of func/var declarations
PAL_C_LINKAGE_END    ---- Use this at the end of func/var declarations
LouYihua 7 years ago
parent
commit
bb3671e5ed
35 changed files with 143 additions and 239 deletions
  1. 5 0
      android/jni/src/pal_config.h
  2. 0 9
      ascii.h
  3. 3 8
      audio.h
  4. 3 8
      battle.h
  5. 0 8
      codepage.h
  6. 7 6
      common.h
  7. 5 7
      ending.h
  8. 5 7
      fight.h
  9. 2 7
      font.h
  10. 0 9
      fontglyph.h
  11. 1 0
      game.h
  12. 3 8
      global.h
  13. 5 10
      input.h
  14. 4 0
      ios/pal_config.h
  15. 6 7
      itemmenu.h
  16. 5 7
      magicmenu.h
  17. 4 9
      map.h
  18. 4 10
      midi.h
  19. 9 0
      native_midi/native_midi.h
  20. 4 8
      palcfg.h
  21. 5 10
      palcommon.h
  22. 2 7
      palette.h
  23. 4 7
      play.h
  24. 4 10
      players.h
  25. 4 7
      res.h
  26. 1 9
      rngplay.h
  27. 4 7
      scene.h
  28. 4 7
      script.h
  29. 6 0
      text.h
  30. 3 8
      ui.h
  31. 5 8
      uibattle.h
  32. 5 8
      uigame.h
  33. 10 11
      util.h
  34. 7 12
      video.h
  35. 4 0
      winrt/pal_config.h

+ 5 - 0
android/jni/src/pal_config.h

@@ -27,6 +27,8 @@
 
 # define PAL_IS_VALID_JOYSTICK(s)  (strcmp((s), "Android Accelerometer") != 0)
 
+PAL_C_LINKAGE_BEGIN
+
 LPCSTR
 UTIL_BasePath(
    VOID
@@ -36,4 +38,7 @@ LPCSTR
 UTIL_SavePath(
    VOID
 );
+
+PAL_C_LINKAGE_END
+
 #endif

+ 0 - 9
ascii.h

@@ -5,11 +5,6 @@
 #ifndef _FONT_C
 #error "This file should only be included inside font.c!"
 #endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
 	
 static unsigned char iso_font[] =
 {
@@ -435,8 +430,4 @@ static unsigned char iso_font_8x8[256][8] = {
 	{ 0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F }    // U+00FF (y umlaut)
 };
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif

+ 3 - 8
audio.h

@@ -24,10 +24,7 @@
 
 #include "common.h"
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+PAL_C_LINKAGE_BEGIN
 
 INT
 AUDIO_OpenDevice(
@@ -91,10 +88,8 @@ AUDIO_SoundEnabled(
    VOID
 );
 
-#define AUDIO_IsIntegerConversion(a) (((a) % gConfig.iSampleRate) == 0 || (gConfig.iSampleRate % (a)) == 0)
+PAL_C_LINKAGE_END
 
-#ifdef __cplusplus
-}
-#endif
+#define AUDIO_IsIntegerConversion(a) (((a) % gConfig.iSampleRate) == 0 || (gConfig.iSampleRate % (a)) == 0)
 
 #endif

+ 3 - 8
battle.h

@@ -22,11 +22,6 @@
 #ifndef BATTLE_H
 #define BATTLE_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 #include "global.h"
 #include "uibattle.h"
 
@@ -194,6 +189,8 @@ typedef struct tagBATTLE
 #endif
 } BATTLE;
 
+PAL_C_LINKAGE_BEGIN
+
 extern BATTLE g_Battle;
 
 VOID
@@ -227,8 +224,6 @@ PAL_StartBattle(
    BOOL        fIsBoss
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 0 - 8
codepage.h

@@ -29,11 +29,6 @@
 #error "This file should only be included inside text.c!"
 #endif
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 static WCHAR cptbl_gbk[126][192] = {
   {
     0x4E02,0x4E04,0x4E05,0x4E06,0x4E0F,0x4E12,0x4E17,0x4E1F,0x4E20,0x4E21,0x4E23,0x4E26,0x4E29,0x4E2E,0x4E2F,0x4E31,
@@ -4170,8 +4165,5 @@ static WCHAR cptbl_jis_half[64] = {
 	0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
 };
 */
-#ifdef __cplusplus
-}
-#endif
 
 #endif

+ 7 - 6
common.h

@@ -147,8 +147,13 @@ typedef const WCHAR        *LPCWSTR;
 #endif
 
 #ifdef __cplusplus
-extern "C"
-{
+# define PAL_C_LINKAGE       extern "C"
+# define PAL_C_LINKAGE_BEGIN PAL_C_LINKAGE {
+# define PAL_C_LINKAGE_END   }
+#else
+# define PAL_C_LINKAGE
+# define PAL_C_LINKAGE_BEGIN
+# define PAL_C_LINKAGE_END
 #endif
 
 /* When porting SDLPAL to a new platform, please make a separate directory and put a file 
@@ -215,8 +220,4 @@ typedef enum tagCODEPAGE {
 	CP_UTF_8 = CP_MAX + 1
 } CODEPAGE;
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif

+ 5 - 7
ending.h

@@ -22,10 +22,9 @@
 #ifndef ENDGAME_H
 #define ENDGAME_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
+
+PAL_C_LINKAGE_BEGIN
 
 VOID
 PAL_EndingSetEffectSprite(
@@ -55,7 +54,6 @@ PAL_EndingScreen(
    VOID
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
+
 #endif

+ 5 - 7
fight.h

@@ -22,10 +22,9 @@
 #ifndef FIGHT_H
 #define FIGHT_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
+
+PAL_C_LINKAGE_BEGIN
 
 INT
 PAL_BattleSelectAutoTarget(
@@ -102,7 +101,6 @@ PAL_BattleSimulateMagic(
    WORD       wBaseDamage
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
+
 #endif

+ 2 - 7
font.h

@@ -27,10 +27,7 @@
 #include "common.h"
 #include "palcommon.h"
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+PAL_C_LINKAGE_BEGIN
 
 INT
 PAL_InitEmbeddedFont(
@@ -66,8 +63,6 @@ PAL_FontHeight(
    VOID
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 0 - 9
fontglyph.h

@@ -29,11 +29,6 @@
 #error "This file should only be included inside font.c!"
 #endif
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 static unsigned char unicode_font[][32] = {
   { 170,170,0,1,128,0,0,1,128,0,74,81,234,80,90,81,201,158,0,1,128,0,0,1,128,0,0,1,128,0,85,85 },
   { 170,170,0,1,128,0,0,1,128,0,57,147,194,82,50,95,138,82,113,147,128,0,0,1,128,0,0,1,128,0,85,85 },
@@ -58913,8 +58908,4 @@ unsigned char font_width[] = {
 static const int unicode_upper_base = 0xf900;
 static const int unicode_upper_top  = 65534;
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif

+ 1 - 0
game.h

@@ -27,6 +27,7 @@
 #define    FPS             10
 #define    FRAME_TIME      (1000 / FPS)
 
+PAL_C_LINKAGE
 VOID
 PAL_GameMain(
    VOID

+ 3 - 8
global.h

@@ -29,11 +29,6 @@
 #include "map.h"
 #include "ui.h"
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 //
 // SOME NOTES ON "AUTO SCRIPT" AND "TRIGGER SCRIPT":
 //
@@ -617,6 +612,8 @@ typedef struct tagGLOBALVARS
    DWORD            dwFrameNum;
 } GLOBALVARS, *LPGLOBALVARS;
 
+PAL_C_LINKAGE_BEGIN
+
 extern GLOBALVARS * const gpGlobals;
 
 BOOL
@@ -796,8 +793,6 @@ PAL_PlayerLevelUp(
    WORD          wNumLevel
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 5 - 10
input.h

@@ -25,19 +25,12 @@
 #include "common.h"
 #include "palcommon.h"
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 typedef struct tagPALINPUTSTATE
 {
    PALDIRECTION           dir, prevdir;
    DWORD                  dwKeyPress;
 } PALINPUTSTATE;
 
-extern volatile PALINPUTSTATE g_InputState;
-
 enum PALKEY
 {
    kKeyMenu        = (1 << 0),
@@ -60,6 +53,8 @@ enum PALKEY
    kKeyEnd         = (1 << 17),
 };
 
+PAL_C_LINKAGE_BEGIN
+
 VOID
 PAL_ClearKeyState(
    VOID
@@ -99,10 +94,10 @@ PAL_RegisterInputFilter(
    void (*shutdown_filter)()
 );
 
+extern volatile PALINPUTSTATE g_InputState;
+
 extern BOOL g_fUseJoystick;
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 4 - 0
ios/pal_config.h

@@ -25,6 +25,8 @@
 
 #define PAL_HAS_CONFIG_PAGE 0
 
+PAL_C_LINKAGE_BEGIN
+
 LPCSTR
 UTIL_BasePath(
    VOID
@@ -35,6 +37,8 @@ UTIL_SavePath(
    VOID
 );
 
+PAL_C_LINKAGE_END
+
 #include <sys/time.h>
 
 #endif

+ 6 - 7
itemmenu.h

@@ -22,10 +22,10 @@
 #ifndef ITEMMENU_H
 #define ITEMMENU_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
+#include "ui.h"
+
+PAL_C_LINKAGE_BEGIN
 
 WORD
 PAL_ItemSelectMenuUpdate(
@@ -43,7 +43,6 @@ PAL_ItemSelectMenu(
    WORD                      wItemFlags
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
+
 #endif

+ 5 - 7
magicmenu.h

@@ -22,10 +22,9 @@
 #ifndef MAGICMENU_H
 #define MAGICMENU_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
+
+PAL_C_LINKAGE_BEGIN
 
 WORD
 PAL_MagicSelectionMenuUpdate(
@@ -46,7 +45,6 @@ PAL_MagicSelectionMenu(
    WORD         wDefaultMagic
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
+
 #endif

+ 4 - 9
map.h

@@ -22,11 +22,6 @@
 #ifndef _MAP_H
 #define _MAP_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 #include "common.h"
 
 //
@@ -70,6 +65,8 @@ typedef struct tagPALMAP
 
 typedef const PALMAP *LPCPALMAP;
 
+PAL_C_LINKAGE_BEGIN
+
 LPPALMAP
 PAL_LoadMap(
    INT               iMapNum,
@@ -116,6 +113,8 @@ PAL_MapBlitToSurface(
    BYTE                  ucLayer
 );
 
+PAL_C_LINKAGE_END
+
 //
 // Convert map location to the real location
 //
@@ -132,8 +131,4 @@ PAL_MapBlitToSurface(
    (y) = (BYTE)(PAL_Y(pos) / 16);                     \
 }
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif

+ 4 - 10
midi.h

@@ -24,13 +24,11 @@
 
 #include "common.h"
 
-#ifdef __cplusplus
-extern "C"
-{
+#if PAL_HAS_NATIVEMIDI
+# include "native_midi/native_midi.h"
 #endif
 
-#if PAL_HAS_NATIVEMIDI
-#include "native_midi/native_midi.h"
+PAL_C_LINKAGE_BEGIN
 
 VOID
 MIDI_Play(
@@ -43,10 +41,6 @@ MIDI_CheckLoop(
    VOID
 );
 
-#endif
-
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 9 - 0
native_midi/native_midi.h

@@ -27,6 +27,11 @@
 
 typedef struct _NativeMidiSong NativeMidiSong;
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 int native_midi_detect();
 NativeMidiSong *native_midi_loadsong(const char *midifile);
 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw);
@@ -37,4 +42,8 @@ int native_midi_active();
 void native_midi_setvolume(int volume);
 const char *native_midi_error(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _NATIVE_MIDI_H_ */

+ 4 - 8
palcfg.h

@@ -22,11 +22,7 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
-# ifdef __cplusplus
-extern "C"
-{
-# endif
-
+#include "common.h"
 #include "palcommon.h"
 
 #define     PAL_MAX_SAMPLERATE           48000
@@ -197,6 +193,8 @@ typedef struct tagCONFIGURATION
 #endif
 } CONFIGURATION, *LPCONFIGURATION;
 
+PAL_C_LINKAGE_BEGIN
+
 extern CONFIGURATION gConfig;
 
 VOID
@@ -232,8 +230,6 @@ PAL_LimitConfig(
 	ConfigValue * pValue
 );
 
-# ifdef __cplusplus
-}
-# endif
+PAL_C_LINKAGE_END
 
 #endif

+ 5 - 10
palcommon.h

@@ -24,11 +24,6 @@
 
 #include "common.h"
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 typedef LPBYTE      LPSPRITE, LPBITMAPRLE;
 typedef LPCBYTE     LPCSPRITE, LPCBITMAPRLE;
 
@@ -50,7 +45,9 @@ typedef enum tagPALDIRECTION
    kDirEast,
    kDirUnknown
 } PALDIRECTION, *LPPALDIRECTION;
-    
+
+PAL_C_LINKAGE_BEGIN
+
 INT
 PAL_RLEBlitToSurface(
    LPCBITMAPRLE      lpBitmapRLE,
@@ -165,6 +162,8 @@ YJ2_Decompress(
    INT          DestSize
 );
 
+PAL_C_LINKAGE_END
+
 #define PAL_DelayUntil(t) \
    PAL_ProcessEvent(); \
    while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
@@ -173,8 +172,4 @@ YJ2_Decompress(
       SDL_Delay(1); \
    }
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif // _PALUTILS_H

+ 2 - 7
palette.h

@@ -24,10 +24,7 @@
 
 #include "common.h"
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+PAL_C_LINKAGE_BEGIN
 
 SDL_Color *
 PAL_GetPalette(
@@ -79,8 +76,6 @@ PAL_FadeToRed(
    VOID
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 4 - 7
play.h

@@ -22,10 +22,9 @@
 #ifndef PLAY_H
 #define PLAY_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
+
+PAL_C_LINKAGE_BEGIN
 
 VOID
 PAL_GameUpdate(
@@ -52,8 +51,6 @@ PAL_WaitForKey(
    WORD      wTimeOut
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 4 - 10
players.h

@@ -25,14 +25,8 @@
 
 #include "common.h"
 
-#ifdef __cplusplus
-
-extern "C"
+typedef struct tagAUDIOPLAYER
 {
-#endif
-
-	typedef struct tagAUDIOPLAYER
-	{
 #define AUDIOPLAYER_COMMONS \
 	VOID (*Shutdown)(VOID*); \
 	BOOL (*Play)(VOID*, INT, BOOL, FLOAT); \
@@ -41,6 +35,8 @@ extern "C"
 	AUDIOPLAYER_COMMONS;
 } AUDIOPLAYER, *LPAUDIOPLAYER;
 
+PAL_C_LINKAGE_BEGIN
+
 /* RIX */
 
 LPAUDIOPLAYER
@@ -73,8 +69,6 @@ SOUND_Init(
 	VOID
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 4 - 7
res.h

@@ -22,10 +22,7 @@
 #ifndef RES_H
 #define RES_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
 
 typedef enum tagLOADRESFLAG
 {
@@ -33,6 +30,8 @@ typedef enum tagLOADRESFLAG
    kLoadPlayerSprite   = (1 << 1),    // load player sprites
 } LOADRESFLAG, *LPLOADRESFLAG;
 
+PAL_C_LINKAGE_BEGIN
+
 VOID
 PAL_InitResources(
    VOID
@@ -73,8 +72,6 @@ PAL_GetEventObjectSprite(
    WORD      wEventObjectID
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 1 - 9
rngplay.h

@@ -22,13 +22,9 @@
 #ifndef RNGPLAY_H
 #define RNGPLAY_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 #include "common.h"
 
+PAL_C_LINKAGE
 VOID
 PAL_RNGPlay(
    INT           iNumRNG,
@@ -37,8 +33,4 @@ PAL_RNGPlay(
    INT           iSpeed
 );
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif

+ 4 - 7
scene.h

@@ -22,10 +22,9 @@
 #ifndef _SCENE_H
 #define	_SCENE_H
 
-#ifdef	__cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
+
+PAL_C_LINKAGE_BEGIN
 
 VOID
 PAL_ApplyWave(
@@ -60,8 +59,6 @@ PAL_NPCWalkOneStep(
    INT           iSpeed
 );
 
-#ifdef	__cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 4 - 7
script.h

@@ -22,13 +22,12 @@
 #ifndef SCRIPT_H
 #define SCRIPT_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include "common.h"
 
 #define PAL_ITEM_DESC_BOTTOM	(1 << 15)
 
+PAL_C_LINKAGE_BEGIN
+
 WORD
 PAL_RunTriggerScript(
    WORD           wScriptEntry,
@@ -43,8 +42,6 @@ PAL_RunAutoScript(
 
 extern BOOL       g_fScriptSuccess;
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 6 - 0
text.h

@@ -24,6 +24,8 @@
 #ifndef _TEXT_H
 #define _TEXT_H
 
+#include "common.h"
+
 typedef enum tagDIALOGPOSITION
 {
    kDialogUpper       = 0,
@@ -32,6 +34,8 @@ typedef enum tagDIALOGPOSITION
    kDialogCenterWindow
 } DIALOGLOCATION;
 
+PAL_C_LINKAGE_BEGIN
+
 extern LPWSTR g_rcCredits[12];
 
 INT
@@ -138,4 +142,6 @@ PAL_swprintf(
 	...
 );
 
+PAL_C_LINKAGE_END
+
 #endif

+ 3 - 8
ui.h

@@ -24,11 +24,6 @@
 #ifndef UI_H
 #define UI_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 #include "common.h"
 
 #define CHUNKNUM_SPRITEUI                  9
@@ -175,6 +170,8 @@ typedef enum tagNUMALIGN
    kNumAlignRight
 } NUMALIGN;
 
+PAL_C_LINKAGE_BEGIN
+
 INT
 PAL_InitUI(
    VOID
@@ -282,8 +279,6 @@ PAL_GetObjectDesc(
 
 extern LPSPRITE gpSpriteUI;
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 5 - 8
uibattle.h

@@ -24,11 +24,7 @@
 #ifndef UIBATTLE_H
 #define UIBATTLE_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
+#include "common.h"
 #include "ui.h"
 
 typedef enum tagBATTLEUISTATE
@@ -117,6 +113,8 @@ typedef struct tagBATTLEUI
    SHOWNUM          rgShowNum[BATTLEUI_MAX_SHOWNUM];
 } BATTLEUI;
 
+PAL_C_LINKAGE_BEGIN
+
 VOID
 PAL_PlayerInfoBox(
    PAL_POS         pos,
@@ -149,7 +147,6 @@ PAL_BattleUIShowNum(
    NUMCOLOR       color
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
+
 #endif

+ 5 - 8
uigame.h

@@ -24,13 +24,11 @@
 #ifndef UIGAME_H
 #define UIGAME_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
+#include "common.h"
 #include "ui.h"
 
+PAL_C_LINKAGE_BEGIN
+
 VOID
 PAL_DrawOpeningMenuBackground(
    VOID
@@ -101,7 +99,6 @@ PAL_QuitGame(
    VOID
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
+
 #endif

+ 10 - 11
util.h

@@ -27,10 +27,7 @@
 
 //#define ENABLE_LOG 1
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+PAL_C_LINKAGE_BEGIN
 
 void
 UTIL_MsgBox(
@@ -135,6 +132,8 @@ UTIL_Platform_Quit(
    VOID
 );
 
+PAL_C_LINKAGE_END
+
 #define LOG_EMERG           0 /* system is unusable */
 #define LOG_ALERT           1 /* action must be taken immediately */
 #define LOG_CRIT            2 /* critical conditions */
@@ -147,6 +146,8 @@ UTIL_Platform_Quit(
 
 #ifdef ENABLE_LOG
 
+PAL_C_LINKAGE_BEGIN
+
 FILE *
 UTIL_OpenLog(
    VOID
@@ -164,16 +165,14 @@ UTIL_WriteLog(
    ...
 );
 
-#else
+PAL_C_LINKAGE_END
 
-#define UTIL_OpenLog()       ((void)(0))
-#define UTIL_CloseLog()      ((void)(0))
-#define UTIL_WriteLog(...)   ((void)(0))
+#else
 
-#endif
+# define UTIL_OpenLog()       ((void)(0))
+# define UTIL_CloseLog()      ((void)(0))
+# define UTIL_WriteLog(...)   ((void)(0))
 
-#ifdef __cplusplus
-}
 #endif
 
 #endif

+ 7 - 12
video.h

@@ -22,23 +22,20 @@
 #ifndef VIDEO_H
 #define VIDEO_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 #include "common.h"
 
-extern SDL_Surface *gpScreen;
-extern SDL_Surface *gpScreenBak;
-extern volatile BOOL g_bRenderPaused;
-
 #define VIDEO_CopySurface(s, sr, t, tr) SDL_BlitSurface((s), (sr), (t), (tr))
 #define VIDEO_CopyEntireSurface(s, t)   SDL_BlitSurface((s), NULL, (t), NULL)
 #define VIDEO_BackupScreen(s)           SDL_BlitSurface((s), NULL, gpScreenBak, NULL)
 #define VIDEO_RestoreScreen(t)          SDL_BlitSurface(gpScreenBak, NULL, (t), NULL)
 #define VIDEO_FreeSurface(s)            SDL_FreeSurface(s)
 
+PAL_C_LINKAGE_BEGIN
+
+extern SDL_Surface *gpScreen;
+extern SDL_Surface *gpScreenBak;
+extern volatile BOOL g_bRenderPaused;
+
 INT
 VIDEO_Startup(
    VOID
@@ -118,8 +115,6 @@ VIDEO_UpdateSurfacePalette(
 	SDL_Surface    *pSource
 );
 
-#ifdef __cplusplus
-}
-#endif
+PAL_C_LINKAGE_END
 
 #endif

+ 4 - 0
winrt/pal_config.h

@@ -27,6 +27,8 @@
 
 #define PAL_FILESYSTEM_IGNORE_CASE 1
 
+PAL_C_LINKAGE_BEGIN
+
 LPCSTR
 UTIL_BasePath(
    VOID
@@ -51,3 +53,5 @@ BOOL
 UTIL_TouchEnabled(
    VOID
 );
+
+PAL_C_LINKAGE_END