-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
At runtime you can do this to get offset:
var a: A = undefined;
assert(@ptrToInt(&a.a) - @ptrToInt(&a) == @byteOffsetOf(A, "a"));
We could make this work at compile time with the concept of lazy evaluated comptime values. For example even though we don't know the actual integer address of &a
at comptime or of &a.a
, if the only thing the comptime code does with these values is subtract them, we can have that return the offset. That means we can delete @byteOffsetOf
and make it a userland function.
As for @bitOffsetOf
something similar could be done with taking the address of a bit packed field, plus @typeInfo
, since the bit offset information is in the pointer type.
Metadata
Metadata
Assignees
Labels
proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.