|
47 | 47 | #define UNITY_FUNCTION_ATTR(a) /* ignore */ |
48 | 48 | #endif |
49 | 49 |
|
50 | | -#ifndef UNITY_NORETURN |
51 | | - #if defined(__cplusplus) |
52 | | - #if __cplusplus >= 201103L |
| 50 | +/* UNITY_NORETURN is only required if we have setjmp.h. */ |
| 51 | +#ifndef UNITY_EXCLUDE_SETJMP_H |
| 52 | + #ifndef UNITY_NORETURN |
| 53 | + #if defined(__cplusplus) |
| 54 | + #if __cplusplus >= 201103L |
| 55 | + #define UNITY_NORETURN [[ noreturn ]] |
| 56 | + #endif |
| 57 | + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && __STDC_VERSION__ < 202311L |
| 58 | + /* _Noreturn keyword is used from C11 but deprecated in C23. */ |
| 59 | + #if defined(_WIN32) && defined(_MSC_VER) |
| 60 | + /* We are using MSVC compiler on Windows platform. */ |
| 61 | + /* Not all Windows SDKs supports <stdnoreturn.h>, but compiler can support C11: */ |
| 62 | + /* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */ |
| 63 | + /* Not sure, that Mingw compilers has Windows SDK headers at all. */ |
| 64 | + #include <sdkddkver.h> |
| 65 | + #endif |
| 66 | + |
| 67 | + /* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */ |
| 68 | + /* Mingw GCC should work without that fixes. */ |
| 69 | + /* Based on: */ |
| 70 | + /* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */ |
| 71 | + /* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */ |
| 72 | + #if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE) |
| 73 | + /* Based on tests and: */ |
| 74 | + /* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */ |
| 75 | + /* https://en.cppreference.com/w/c/language/_Noreturn */ |
| 76 | + #define UNITY_NORETURN _Noreturn |
| 77 | + #else /* Using newer Windows SDK or not MSVC compiler */ |
| 78 | + #if defined(__GNUC__) |
| 79 | + /* The header <stdnoreturn.h> collides with __attribute(noreturn)__ from GCC. */ |
| 80 | + #define UNITY_NORETURN _Noreturn |
| 81 | + #else |
| 82 | + #include <stdnoreturn.h> |
| 83 | + #define UNITY_NORETURN noreturn |
| 84 | + #endif |
| 85 | + #endif |
| 86 | + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L |
| 87 | + /* Since C23, the keyword _Noreturn has been replaced by the attribute noreturn, based on: */ |
| 88 | + /* https://en.cppreference.com/w/c/language/attributes/noreturn */ |
53 | 89 | #define UNITY_NORETURN [[ noreturn ]] |
54 | 90 | #endif |
55 | | - #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
56 | | - #if defined(_WIN32) && defined(_MSC_VER) |
57 | | - /* We are using MSVC compiler on Windows platform. */ |
58 | | - /* Not all Windows SDKs supports <stdnoreturn.h>, but compiler can support C11: */ |
59 | | - /* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */ |
60 | | - /* Not sure, that Mingw compilers has Windows SDK headers at all. */ |
61 | | - #include <sdkddkver.h> |
62 | | - #endif |
63 | | - |
64 | | - /* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */ |
65 | | - /* Mingw GCC should work without that fixes. */ |
66 | | - /* Based on: */ |
67 | | - /* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */ |
68 | | - /* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */ |
69 | | - #if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE) |
70 | | - /* Based on tests and: */ |
71 | | - /* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */ |
72 | | - /* https://en.cppreference.com/w/c/language/_Noreturn */ |
73 | | - #define UNITY_NORETURN _Noreturn |
74 | | - #else /* Using newer Windows SDK or not MSVC compiler */ |
75 | | - #include <stdnoreturn.h> |
76 | | - #define UNITY_NORETURN noreturn |
77 | | - #endif |
78 | 91 | #endif |
79 | | -#endif |
80 | | -#ifndef UNITY_NORETURN |
81 | | - #define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__) |
| 92 | + #ifndef UNITY_NORETURN |
| 93 | + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__) |
| 94 | + #endif |
82 | 95 | #endif |
83 | 96 |
|
84 | 97 | /*------------------------------------------------------- |
|
0 commit comments