sizeof doesn't work for types that store Atomics. This would be useful to size the memory buffer for thread-safe memory allocators with what is left from the synchronization primitives.
import std/atomics
type
Node = ptr object
# works
next: Atomic[pointer]
MyChannel = object
# type not defined completely
back: Atomic[ptr int]
static:
echo sizeof(Node)
echo sizeof(MyChannel)
The workaround is to add a "raw" field for all the trivial types with their actual types so that sizeof works.
There is a similar concern for Locks and Condition Variables though I don't think there is an easy way to make sizeof deduce their size.
sizeofdoesn't work for types that store Atomics. This would be useful to size the memory buffer for thread-safe memory allocators with what is left from the synchronization primitives.The workaround is to add a "raw" field for all the trivial types with their actual types so that sizeof works.
There is a similar concern for Locks and Condition Variables though I don't think there is an easy way to make sizeof deduce their size.