Skip to content

Commit

Permalink
sdl: Disable warnings of old SDL2 version by the default
Browse files Browse the repository at this point in the history
All the old SDL2 version warning messages are now disabled by default. To enable
it, you can set the CGO_CPPFLAGS environment variable such as the following:

CGO_CPPFLAGS=-DWARN_OUTDATED go build

or

CGO_CPPFLAGS=-DWARN_OUTDATED go get -v github.com/veandco/go-sdl2/sdl

Signed-off-by: Lilis Iskandar <[email protected]>
  • Loading branch information
veeableful committed Nov 20, 2018
1 parent 58668ac commit e081255
Show file tree
Hide file tree
Showing 17 changed files with 428 additions and 0 deletions.
36 changes: 36 additions & 0 deletions sdl/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ package sdl
#include "sdl_wrapper.h"
#if !(SDL_VERSION_ATLEAST(2,0,4))
#if defined(WARN_OUTDATED)
#pragma message("SDL_QueueAudio is not supported before SDL 2.0.4")
#endif
static int SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len)
{
return -1;
Expand All @@ -19,7 +23,11 @@ static void SDL_ClearQueuedAudio(SDL_AudioDeviceID dev)
#endif
#if !(SDL_VERSION_ATLEAST(2,0,5))
#if defined(WARN_OUTDATED)
#pragma message("SDL_DequeueAudio is not supported before SDL 2.0.5")
#endif
static int SDL_DequeueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len)
{
return -1;
Expand All @@ -31,43 +39,71 @@ static int SDL_DequeueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len)
struct _SDL_AudioStream;
typedef struct _SDL_AudioStream SDL_AudioStream;
#if defined(WARN_OUTDATED)
#pragma message("SDL_NewAudioStream is not supported before SDL 2.0.7")
#endif
static SDL_AudioStream * SDL_NewAudioStream(const SDL_AudioFormat src_format, const Uint8 src_channels, const int src_rate, const SDL_AudioFormat dst_format, const Uint8 dst_channels, const int dst_rate)
{
return 0;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_AudioStreamPut is not supported before SDL 2.0.7")
#endif
static int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
{
return -1;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_AudioStreamGet is not supported before SDL 2.0.7")
#endif
static int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
{
return -1;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_AudioStreamAvailable is not supported before SDL 2.0.7")
#endif
static int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
{
return -1;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_AudioStreamFlush is not supported before SDL 2.0.7")
#endif
static int SDL_AudioStreamFlush(SDL_AudioStream *stream)
{
return -1;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_AudioStreamClear is not supported before SDL 2.0.7")
#endif
static int SDL_AudioStreamClear(SDL_AudioStream *stream)
{
return -1;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_FreeAudioStream is not supported before SDL 2.0.7")
#endif
static void SDL_FreeAudioStream(SDL_AudioStream *stream)
{
}
Expand Down
16 changes: 16 additions & 0 deletions sdl/blendmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ package sdl
#if !(SDL_VERSION_ATLEAST(2,0,6))
#if defined(WARN_OUTDATED)
#pragma message("SDL_BLENDMODE_INVALID is not supported before SDL 2.0.6")
#endif
#define SDL_BLENDMODE_INVALID (0x7FFFFFFF)
#if defined(WARN_OUTDATED)
#pragma message("SDL_BlendOperation is not supported before SDL 2.0.6")
#endif
typedef enum
{
SDL_BLENDOPERATION_ADD = 0x1,
Expand All @@ -18,7 +26,11 @@ typedef enum
SDL_BLENDOPERATION_MAXIMUM = 0x5
} SDL_BlendOperation;
#if defined(WARN_OUTDATED)
#pragma message("SDL_BlendFactor is not supported before SDL 2.0.6")
#endif
typedef enum
{
SDL_BLENDFACTOR_ZERO = 0x1,
Expand All @@ -34,7 +46,11 @@ typedef enum
} SDL_BlendFactor;
#if defined(WARN_OUTDATED)
#pragma message("SDL_ComposeCustomBlendMode is not supported before SDL 2.0.6")
#endif
SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, SDL_BlendOperation colorOperation, SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, SDL_BlendOperation alphaOperation)
{
return SDL_BLENDMODE_NONE;
Expand Down
16 changes: 16 additions & 0 deletions sdl/cpuinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,47 @@ package sdl
#include "sdl_wrapper.h"
#if !(SDL_VERSION_ATLEAST(2,0,1))
#if defined(WARN_OUTDATED)
#pragma message("SDL_GetSystemRAM is not supported before SDL 2.0.1")
#endif
static inline int SDL_GetSystemRAM()
{
return -1;
}
#endif
#if !(SDL_VERSION_ATLEAST(2,0,2))
#if defined(WARN_OUTDATED)
#pragma message("SDL_HasAVX is not supported before SDL 2.0.2")
#endif
static inline SDL_bool SDL_HasAVX()
{
return SDL_FALSE;
}
#endif
#if !(SDL_VERSION_ATLEAST(2,0,4))
#if defined(WARN_OUTDATED)
#pragma message("SDL_HasAVX2 is not supported before SDL 2.0.4")
#endif
static inline SDL_bool SDL_HasAVX2()
{
return SDL_FALSE;
}
#endif
#if !(SDL_VERSION_ATLEAST(2,0,6))
#if defined(WARN_OUTDATED)
#pragma message("SDL_HasNEON is not supported before SDL 2.0.4")
#endif
static inline SDL_bool SDL_HasNEON()
{
return SDL_FALSE;
Expand Down
32 changes: 32 additions & 0 deletions sdl/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,39 @@ package sdl
#endif
#if !SDL_VERSION_ATLEAST(2,0,4)
#if defined(WARN_OUTDATED)
#pragma message("SDL_KEYMAPCHANGED is not supported before SDL 2.0.4")
#endif
#define SDL_KEYMAPCHANGED (0x304)
#if defined(WARN_OUTDATED)
#pragma message("SDL_AUDIODEVICEADDED is not supported before SDL 2.0.4")
#endif
#define SDL_AUDIODEVICEADDED (0x1100)
#if defined(WARN_OUTDATED)
#pragma message("SDL_AUDIODEVICEREMOVED is not supported before SDL 2.0.4")
#endif
#define SDL_AUDIODEVICEREMOVED (0x1101)
#if defined(WARN_OUTDATED)
#pragma message("SDL_RENDER_DEVICE_RESET is not supported before SDL 2.0.4")
#endif
#define SDL_RENDER_DEVICE_RESET (0x2001)
#if defined(WARN_OUTDATED)
#pragma message("SDL_AudioDeviceEvent is not supported before SDL 2.0.4")
#endif
typedef struct SDL_AudioDeviceEvent
{
Uint32 type;
Expand All @@ -35,13 +55,25 @@ typedef struct SDL_AudioDeviceEvent
#endif
#if !SDL_VERSION_ATLEAST(2,0,5)
#if defined(WARN_OUTDATED)
#pragma message("SDL_DROPTEXT is not supported before SDL 2.0.5")
#endif
#define SDL_DROPTEXT (0x1001)
#if defined(WARN_OUTDATED)
#pragma message("SDL_DROPBEGIN is not supported before SDL 2.0.5")
#endif
#define SDL_DROPBEGIN (0x1002)
#if defined(WARN_OUTDATED)
#pragma message("SDL_DROPCOMPLETE is not supported before SDL 2.0.5")
#endif
#define SDL_DROPCOMPLETE (0x1003)
#endif
Expand Down
8 changes: 8 additions & 0 deletions sdl/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ package sdl
#include "sdl_wrapper.h"
#if !(SDL_VERSION_ATLEAST(2,0,1))
#if defined(WARN_OUTDATED)
#pragma message("SDL_GetBasePath is not supported before SDL 2.0.1")
#endif
static inline char* SDL_GetBasePath()
{
return NULL;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_GetPrefPath is not supported before SDL 2.0.1")
#endif
static inline char* SDL_GetPrefPath(const char *org, const char *app)
{
return NULL;
Expand Down
24 changes: 24 additions & 0 deletions sdl/gamecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,63 @@ package sdl
#include "sdl_wrapper.h"
#if !(SDL_VERSION_ATLEAST(2,0,4))
#if defined(WARN_OUTDATED)
#pragma message("SDL_GameControllerFromInstanceID is not supported before SDL 2.0.4")
#endif
static SDL_GameController* SDL_GameControllerFromInstanceID(SDL_JoystickID joyid)
{
return NULL;
}
#endif
#if !(SDL_VERSION_ATLEAST(2,0,6))
#if defined(WARN_OUTDATED)
#pragma message("SDL_GameControllerGetVendor is not supported before SDL 2.0.6")
#endif
static Uint16 SDL_GameControllerGetVendor(SDL_GameController* gamecontroller)
{
return 0;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_GameControllerGetProduct is not supported before SDL 2.0.6")
#endif
static Uint16 SDL_GameControllerGetProduct(SDL_GameController* gamecontroller)
{
return 0;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_GameControllerGetProductVersion is not supported before SDL 2.0.6")
#endif
static Uint16 SDL_GameControllerGetProductVersion(SDL_GameController* gamecontroller)
{
return 0;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_GameControllerNumMappings is not supported before SDL 2.0.6")
#endif
static int SDL_GameControllerNumMappings(void)
{
return 0;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_GameControllerMappingForIndex is not supported before SDL 2.0.6")
#endif
static char* SDL_GameControllerMappingForIndex(int mapping_index)
{
return NULL;
Expand Down
Loading

0 comments on commit e081255

Please sign in to comment.