Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug #1097
Browse files Browse the repository at this point in the history
There are problems with including intrin.h in C linkage in C++ compilation,
and further conflicts between intrin.h and winnt.h on Visual Studio 2005.
  • Loading branch information
slouken committed Jan 22, 2011
1 parent 4928b13 commit 48df290
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/SDL_atomic.h
Expand Up @@ -56,6 +56,13 @@

#include "begin_code.h"

/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
#include <intrin.h>
#define HAVE_MSC_ATOMICS
#endif

/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
Expand Down Expand Up @@ -112,8 +119,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
*/
#ifndef SDL_DISABLE_ATOMIC_INLINE

#if defined(_MSC_VER)
#include <intrin.h>
#if defined(HAVE_MSC_ATOMICS)

#define SDL_AtomicSet(a, v) _InterlockedExchange((long*)&(a)->value, (v))
#define SDL_AtomicGet(a) ((a)->value)
Expand Down
4 changes: 4 additions & 0 deletions src/atomic/SDL_spinlock.c
Expand Up @@ -24,6 +24,10 @@
#include "SDL_atomic.h"
#include "SDL_timer.h"

/* Don't do the check for Visual Studio 2005, it's safe here */
#if defined(_MSC_VER)
#include <intrin.h>
#endif

/* This function is where all the magic happens... */
SDL_bool
Expand Down

0 comments on commit 48df290

Please sign in to comment.