From a4745a8bd914a5258bbfdb39fecfdfb3f0e36616 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 8 Jan 2025 18:38:30 +0800 Subject: [PATCH] add `static_assert` fallback --- include/pocketpy/common/utils.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/pocketpy/common/utils.h b/include/pocketpy/common/utils.h index ed017423..acea6317 100644 --- a/include/pocketpy/common/utils.h +++ b/include/pocketpy/common/utils.h @@ -1,7 +1,6 @@ #pragma once #include -#include #define PK_REGION(name) 1 @@ -45,6 +44,13 @@ typedef struct RefCounted { do { \ if(--(obj)->rc.count == 0) { \ (obj)->rc.dtor(obj); \ - PK_FREE(obj); \ + PK_FREE(obj); \ } \ } while(0) + +// static assert +#ifndef __cplusplus + #ifndef static_assert + #define static_assert(x, msg) if(!(x)) c11__abort(msg) + #endif +#endif