std-aux: add _nm_unreachable_code() macro to wrap __builtin_unreachable()

This is a GCC-ism, but clang and all our current compiler support it.
This commit is contained in:
Thomas Haller 2022-11-30 09:48:04 +01:00
parent fffdb14887
commit 5ac5d7f8c3
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -75,6 +75,14 @@
/*****************************************************************************/
/* This is mainly used in case of failed assertions. Usually assert() itself
* already ensures that the code path is marked as unreachable, however with
* NDEBUG that might not be the case. We want to mark the code as unreachable
* even with NDEBUG/G_DISABLE_ASSERT. */
#define _nm_unreachable_code() __builtin_unreachable()
/*****************************************************************************/
#ifndef _NM_CC_SUPPORT_AUTO_TYPE
#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)))
#define _NM_CC_SUPPORT_AUTO_TYPE 1