Fixed building SDL applications with Visual Studio and the clang toolset
authorSam Lantinga <slouken@libsdl.org>
Sat, 19 Aug 2017 03:07:44 -0700
changeset 113306ae35c5f7f7b
parent 11329 3ed56acc90ca
child 11331 1e231cf0a347
Fixed building SDL applications with Visual Studio and the clang toolset
Also fixed building 64-bit SDL with clang. 32-bit doesn't build because of the inline assembly for C runtime support.
include/SDL_atomic.h
include/SDL_config_windows.h
include/SDL_cpuinfo.h
src/render/direct3d/SDL_render_d3d.c
     1.1 --- a/include/SDL_atomic.h	Sat Aug 19 02:23:50 2017 -0700
     1.2 +++ b/include/SDL_atomic.h	Sat Aug 19 03:07:44 2017 -0700
     1.3 @@ -118,7 +118,7 @@
     1.4   * The compiler barrier prevents the compiler from reordering
     1.5   * reads and writes to globally visible variables across the call.
     1.6   */
     1.7 -#if defined(_MSC_VER) && (_MSC_VER > 1200)
     1.8 +#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
     1.9  void _ReadWriteBarrier(void);
    1.10  #pragma intrinsic(_ReadWriteBarrier)
    1.11  #define SDL_CompilerBarrier()   _ReadWriteBarrier()
     2.1 --- a/include/SDL_config_windows.h	Sat Aug 19 02:23:50 2017 -0700
     2.2 +++ b/include/SDL_config_windows.h	Sat Aug 19 03:07:44 2017 -0700
     2.3 @@ -157,7 +157,7 @@
     2.4  /* Enable various audio drivers */
     2.5  #define SDL_AUDIO_DRIVER_WASAPI 1
     2.6  #define SDL_AUDIO_DRIVER_DSOUND 1
     2.7 -#define SDL_AUDIO_DRIVER_XAUDIO2    1
     2.8 +#define SDL_AUDIO_DRIVER_XAUDIO2    0
     2.9  #define SDL_AUDIO_DRIVER_WINMM  1
    2.10  #define SDL_AUDIO_DRIVER_DISK   1
    2.11  #define SDL_AUDIO_DRIVER_DUMMY  1
     3.1 --- a/include/SDL_cpuinfo.h	Sat Aug 19 02:23:50 2017 -0700
     3.2 +++ b/include/SDL_cpuinfo.h	Sat Aug 19 03:07:44 2017 -0700
     3.3 @@ -33,6 +33,12 @@
     3.4  /* Need to do this here because intrin.h has C++ code in it */
     3.5  /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
     3.6  #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
     3.7 +#ifdef __clang__
     3.8 +/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */
     3.9 +#undef __MMX__
    3.10 +#undef __SSE__
    3.11 +#undef __SSE2__
    3.12 +#else
    3.13  #include <intrin.h>
    3.14  #ifndef _WIN64
    3.15  #define __MMX__
    3.16 @@ -40,6 +46,7 @@
    3.17  #endif
    3.18  #define __SSE__
    3.19  #define __SSE2__
    3.20 +#endif /* __clang__ */
    3.21  #elif defined(__MINGW64_VERSION_MAJOR)
    3.22  #include <intrin.h>
    3.23  #else
     4.1 --- a/src/render/direct3d/SDL_render_d3d.c	Sat Aug 19 02:23:50 2017 -0700
     4.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Sat Aug 19 03:07:44 2017 -0700
     4.3 @@ -761,6 +761,7 @@
     4.4              const char *error = (const char *)pErrorMsgs->lpVtbl->GetBufferPointer(pErrorMsgs);
     4.5              SDL_SetError("Couldn't assemble shader: %s", error);
     4.6          }
     4.7 +        if (shader_data != NULL)
     4.8  #else
     4.9          const DWORD shader_data[] = {
    4.10              0xffff0200, 0x05000051, 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081,
    4.11 @@ -780,7 +781,7 @@
    4.12              0x80e40000, 0x0000ffff
    4.13          };
    4.14  #endif
    4.15 -        if (shader_data != NULL) {
    4.16 +        {
    4.17              result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_yuv);
    4.18              if (!FAILED(result)) {
    4.19                  renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;