From 23d405bbda0a1fda6152a1d5d660841820060aeb Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 18 Dec 2022 12:40:28 +0100 Subject: [PATCH] Add an unreachable() macro function that panics if reached --- luna/include/luna/Check.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/luna/include/luna/Check.h b/luna/include/luna/Check.h index 37c3b13f..faf75bd7 100644 --- a/luna/include/luna/Check.h +++ b/luna/include/luna/Check.h @@ -1,5 +1,4 @@ #pragma once -#include [[noreturn]] extern bool __check_failed(const char* file, const char* line, const char* func, const char* expr); @@ -23,3 +22,6 @@ __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr); \ } \ } while (0) + +#define unreachable() \ + __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, "Reached unreachable code")