C to D: please help translate this weird macro

Ki Rill rill.ki at yahoo.com
Thu Sep 21 02:57:07 UTC 2023


On Thursday, 21 September 2023 at 02:23:32 UTC, Ki Rill wrote:
> wrote:
>> [...]

Translated it to this eventually:
```D
auto nk_container_of(P, T)(P ptr, T type, const(char)* member)
{
     return cast(T*)(cast(void*)(cast(char*)
         (ptr - __traits(getMember, type, member).offsetof)));
}
```


More information about the Digitalmars-d-learn mailing list