**@ivanitto**: I agree with Varriount that it's best to declare the types in 
Nim along with the correct C type pragmas. You don't have to define the entire 
type, just enough to indicate its semantics to Nim and to identify it in the C 
type system:
    
    
    type
        BoxOfStuff {.final, incompleteStruct, header: "<BoxOfStuff.h>", 
importc: "BoxOfStuff".} = object
        PBox {.header: "<BoxOfStuff.h>", importc: "pBox".} = ptr BoxOfStuff
        
        Warehouse {.header: "<Warehouse.h>", importc: "Warehouse".} = object
            shelf: ptr PBox
    

If you have no other choice, you can (ab)use C's type system, and treat 
Warehouse as its C ABI type, which is just a pointer:
    
    
    type
        WarehouseUnsafeDontDoThis {.distinct.} = pointer
    

This will not work if you have C++ linkage though.

Reply via email to