From 24fce5a36c2cb126f3fc27b34ba368f94941c039 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 12 Jan 2024 07:51:39 +0100 Subject: [PATCH] include/c.h: handle members of const struct MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Trying to copy into a local const struct will lead to a compiler error. By adding a "+ 0" to the argument of __typeof__() the type of the resulting express will loose its constness. Signed-off-by: Thomas Weißschuh --- include/c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/c.h b/include/c.h index 36eb2a9e7f..e353643fdd 100644 --- a/include/c.h +++ b/include/c.h @@ -215,7 +215,7 @@ #define read_unaligned_member(p, m) __extension__ ({ \ size_t offset = offsetof(__typeof__(* p), m); \ - __typeof__(p->m) v; \ + __typeof__(p->m + 0) v; \ memcpy(&v, ((unsigned char *)p) + offset, sizeof(v)); \ v; }) -- 2.47.2