mach icon indicating copy to clipboard operation
mach copied to clipboard

sysaudio: @sizeOf(T) is not the same as @bitSizeOf(T)

Open ypsvlq opened this issue 1 year ago • 0 comments

In https://github.com/hexops/mach/issues/1152, @sizeOf(i24) == 4 was considered a Zig bug, but the Zig documentation suggests this is not the case:

This size may contain padding bytes. If there were two consecutive T in memory, the padding would be the offset in bytes between element at index 0 and the element at index 1. For integer, consider whether you want to use @sizeOf(T) or @typeInfo(T).Int.bits.

The correct approach presumably involves using std.PackedIntSlice or similar in convert{To,From}, but exactly how this should be implemented is not clear. Alternatively, it might be possible to replace i24 with i24_4b (removed in https://github.com/hexops/mach-sysaudio/commit/0a6bb12a6ecb04209547701930e6f1a68dce5d76) (EDIT: after minor testing this does not seem to work)

ypsvlq avatar Apr 30 '24 13:04 ypsvlq