Hello,
for a little project I need a certain memory layout and tried to use the align
pragma to achieve it. The default alignment requirement for an object type
seems to be 4? Using lower values (1 or 2) in the align pragma is therefore
useless, because they are ignored, as outlined in the manual. How can I change
this default value?
Here is an example, the size should be 6, but is actually 8:
type
myType = object
field1 {.align(1).}: uint32
field2 {.align(1).}: uint16
echo "Alignment of myType is: " & $alignof(myType)
doAssert sizeof(myType) == 6, "Actual type size is: " & $sizeof(myType)
Run