diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h index 36c4ca4d8..63b8d3798 100644 --- a/include/SDL3/SDL_stdinc.h +++ b/include/SDL3/SDL_stdinc.h @@ -46,6 +46,7 @@ #ifndef __cplusplus #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(_MSC_VER) && (_MSC_VER >= 1910 /* Visual Studio 2017 */)) || \ defined(SDL_INCLUDE_STDBOOL_H) #include #elif !defined(__bool_true_false_are_defined) && !defined(bool) diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 2bc52204f..c8a157c7a 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -306,12 +306,12 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b) { - return SDL_memcmp(a, b, sizeof(*a)) == 0; + return (SDL_memcmp(a, b, sizeof(*a)) == 0); } BOOL WIN_IsEqualIID(REFIID a, REFIID b) { - return SDL_memcmp(a, b, sizeof(*a)) == 0; + return (SDL_memcmp(a, b, sizeof(*a)) == 0); } void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect) diff --git a/src/filesystem/windows/SDL_sysfsops.c b/src/filesystem/windows/SDL_sysfsops.c index a8f3759ee..f61f93952 100644 --- a/src/filesystem/windows/SDL_sysfsops.c +++ b/src/filesystem/windows/SDL_sysfsops.c @@ -45,7 +45,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enume const size_t patternlen = SDL_strlen(path) + 3; char *pattern = (char *) SDL_malloc(patternlen); if (!pattern) { - return -1; + return false; } // you need a wildcard to enumerate through FindFirstFileEx(), but the wildcard is only checked in the @@ -56,15 +56,14 @@ bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enume WCHAR *wpattern = WIN_UTF8ToStringW(pattern); SDL_free(pattern); if (!wpattern) { - return -1; + return false; } WIN32_FIND_DATAW entw; HANDLE dir = FindFirstFileExW(wpattern, FindExInfoStandard, &entw, FindExSearchNameMatch, NULL, 0); SDL_free(wpattern); if (dir == INVALID_HANDLE_VALUE) { - WIN_SetError("Failed to enumerate directory"); - return -1; + return WIN_SetError("Failed to enumerate directory"); } do { diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index 8bc0ae860..7ca78cbc7 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -518,7 +518,7 @@ bool SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect) SDL_ClearError(); - return SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]); + return (SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]) > 0); } bool SDL_SetHapticGain(SDL_Haptic *haptic, int gain) diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 30c7838e2..d22ebff19 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -455,7 +455,7 @@ bool SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) return false; } - return WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance); + return (WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance) == TRUE); } bool SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) @@ -1052,13 +1052,14 @@ int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *e ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status); if (FAILED(ret)) { - return DI_SetError("Getting effect status", ret); + DI_SetError("Getting effect status", ret); + return -1; } if (status == 0) { - return false; + return 0; } - return true; + return 1; } bool SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 53afe1561..fcc6565ec 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -1505,7 +1505,7 @@ bool SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy) SDL_LockJoysticks(); { - CHECK_JOYSTICK_MAGIC(joystick, -1); + CHECK_JOYSTICK_MAGIC(joystick, false); if (ball < joystick->nballs) { if (dx) { diff --git a/src/storage/steam/SDL_steamstorage.c b/src/storage/steam/SDL_steamstorage.c index ca0188ee7..743d50f20 100644 --- a/src/storage/steam/SDL_steamstorage.c +++ b/src/storage/steam/SDL_steamstorage.c @@ -95,7 +95,7 @@ static bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destin static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length) { - int result = false; + bool result = false; STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata; void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016(); if (steamremotestorage == NULL) { diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index c408bc782..ba959c2b5 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -119,7 +119,7 @@ static bool SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mute mutex->count = 0; mutex->owner = 0; - result = pSleepConditionVariableSRW(&cond->cond, &mutex->srw, timeout, 0); + result = (pSleepConditionVariableSRW(&cond->cond, &mutex->srw, timeout, 0) == TRUE); // The mutex is owned by us again, regardless of status of the wait SDL_assert(mutex->count == 0 && mutex->owner == 0); @@ -130,7 +130,7 @@ static bool SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mute SDL_assert(SDL_mutex_impl_active.Type == SDL_MUTEX_CS); - result = pSleepConditionVariableCS(&cond->cond, &mutex->cs, timeout); + result = (pSleepConditionVariableCS(&cond->cond, &mutex->cs, timeout) == TRUE); } return result; diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index da6542507..bd82322d2 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -157,7 +157,7 @@ static void SDL_LockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS / static bool SDL_TryLockMutex_cs(SDL_Mutex *mutex_) { SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; - return TryEnterCriticalSection(&mutex->cs); + return (TryEnterCriticalSection(&mutex->cs) == TRUE); } static void SDL_UnlockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes