yohhoyの日記

技術的メモをしていきたい日記

2025-09-05から1日間の記事一覧

式static_assert in C言語

C

プログラミング言語Cにおいて、式(expression)として扱えるコンパイル時アサートの実装例(C99以降)。*1 *2 #include <assert.h> #define static_assert_expr(cexp_, msg_) \ ((void)sizeof(struct { \ static_assert(cexp_, msg_); \ int dummy_member; \ })) C言語</assert.h>…