From f9f7a0ab5b23508cf3ccbba744476f289b4db9ce Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Fri, 6 Oct 2023 04:11:52 +0200 Subject: [PATCH] cgen: don't subtract null ptr in `__offsetof` --- vlib/v/gen/c/cheaders.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index 47ca63cf58cc49..fe8c68c4698a55 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -360,7 +360,7 @@ const c_common_macros = ' // for __offset_of #ifndef __offsetof - #define __offsetof(PTYPE,FIELDNAME) ((size_t)((char *)&((PTYPE *)0)->FIELDNAME - (char *)0)) + #define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME)) #endif #define OPTION_CAST(x) (x)