From: Mathias Berchtold Date: Sat, 21 Feb 2026 22:01:11 +0000 (-0700) Subject: Add MSVC support for Z_UNREACHABLE macro X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e615eeeef2ce65cd156253e6068e2bce303ccfc8;p=thirdparty%2Fzlib-ng.git Add MSVC support for Z_UNREACHABLE macro Add Z_UNREACHABLE fallback for MSVC, as the C23 unreachable macro is not yet defined in the Windows SDK's . --- diff --git a/zbuild.h b/zbuild.h index 39903d217..c6a54e0f1 100644 --- a/zbuild.h +++ b/zbuild.h @@ -53,7 +53,11 @@ /* Hint to compiler that a block of code is unreachable, typically in a switch default condition */ #ifndef Z_UNREACHABLE # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L -# define Z_UNREACHABLE() unreachable() // C23 approach +# if !defined(unreachable) && defined(_MSC_VER) +# define Z_UNREACHABLE() __assume(0) +# else +# define Z_UNREACHABLE() unreachable() // C23 approach +# endif # elif (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__) # define Z_UNREACHABLE() __builtin_unreachable() # else