[Issue 23067] New: importC: offsetof macro assumes size_t is defined
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 28 06:55:03 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23067
Issue ID: 23067
Summary: importC: offsetof macro assumes size_t is defined
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: minor
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: duser at neet.fi
CC: duser at neet.fi
the __builtin_offsetof macro in druntime uses size_t to cast the result type,
but size_t isn't a built-in type in C so it only works after the type has been
defined
struct S { int x; };
//int y = __builtin_offsetof(struct S, x);
int y = ((size_t)((char *)&((struct S *)0)->x - (char *)0));
test.c(3): Error: undefined identifier `size_t`
when the typeof() PR is merged, this can be fixed by using "typeof(sizeof(0))"
to get the size_t type in the macro
--
More information about the Digitalmars-d-bugs
mailing list