#pragma pack(push, n) equivalent for Nim Objects

2024-01-04 Thread emg
Ok I think the following compiles and works as expected. type TestObj {.packed.} = object m_1 {.align(8).} : int64 m2 {.align(8).}: float64 m3 {.align(8).}: uint8 Run It would be great if we could set the alignment for all object fi

#pragma pack(push, n) equivalent for Nim Objects

2024-01-04 Thread emg
Thanks for your reply. I don't necessarily need them always tightly packed, but with a byte boundary. The 'n' byte part in the C pragma compiler directive. Is it possible to do like this? I tried but it doesn't seem to compile. type TestObj {.packed(8).} = object m_1

#pragma pack(push, n) equivalent for Nim Objects

2024-01-03 Thread emg
Hi, I'm trying to create Nim bindings for an arcane C API that uses struct packing specified using #pragma pack(push, n) all over the headers. What is the most effective way to achieve such struct packing in Nim Objects. Here's an example in C #pragma pack(push, 8) struct A {