Host Pointer Size Not Exposed At Comptime #14568
Labels
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Zig Version
0.10.0-dev.4707+209a0d2a8
Steps to Reproduce and Observed Behavior
Pointers to fields within a packed struct have a field bit-width in bits and a 'pointer host size' (size of the backing integer in bytes) attached to them that are not part of normal pointers.
This information can be provided when creating a pointer through the 'align' keyword, as in the following program which creates a pointer to a field in a packed struct and prints out the information about the pointer that is available through '@typeinfo':
However, once the pointer has been created there is no way to retrieve this information. It is not exposed through std.builtin.Type.
I believe that field width could be determined from std.builtin.Type.Pointer.child using '@bitSizeOf' (perhaps I'm missing a detail there), but the 'host pointer size' is not available.
Without this information, I cannot extract and store this information to later re-synthesize the pointer if it points within a packed struct.
Expected Behavior
I expect to be able to retrieve all information about a pointer using '@typeinfo' including the 'host pointer size'.
More generally: I expect that a pointer can be mapped to a std.builtin.Type structure and back without loss of information.
The text was updated successfully, but these errors were encountered: