1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 08:25:58 +01:00

Merge pull request #604 from AJIOB/old_windows_sdk_fix

Fixing noreturn usage on old Windows SDKs with new MSVC compiler.

Thanks Alex! Sorry about the delay!
This commit is contained in:
Mark VanderVoord
2022-03-14 06:46:40 -04:00
committed by GitHub

View File

@@ -52,8 +52,28 @@
#define UNITY_NORETURN [[ noreturn ]]
#endif
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include <stdnoreturn.h>
#define UNITY_NORETURN noreturn
#if defined(_WIN32) && defined(_MSC_VER)
/* We are using MSVC compiler on Windows platform. */
/* Not all Windows SDKs supports <stdnoreturn.h>, but compiler can support C11: */
/* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */
/* Not sure, that Mingw compilers has Windows SDK headers at all. */
#include <sdkddkver.h>
#endif
/* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */
/* Mingw GCC should work without that fixes. */
/* Based on: */
/* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */
/* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */
#if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE)
/* Based on tests and: */
/* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */
/* https://en.cppreference.com/w/c/language/_Noreturn */
#define UNITY_NORETURN _Noreturn
#else /* Using newer Windows SDK or not MSVC compiler */
#include <stdnoreturn.h>
#define UNITY_NORETURN noreturn
#endif
#endif
#endif
#ifndef UNITY_NORETURN