Ok cool, I get it. So Nim's default is to pass objects to procs via reference, 
right? So if I wanted to do that, while keeping the original C function names 
and only using pass-by-value value when calling them, would this be ok?
    
    
    type
      OriginalMyStruct* {.bycopy.} = object
        id*: cuint
        width*: cfloat
        height*: cfloat
        mipmaps*: cint
        format*: cint
      
      MyStruct = ref OriginalMyStruct
    
    proc OriginalPrintStructValues(testStruct: OriginalMyStruct)
      {.cdecl, importc: "PrintStructValues", dynlib: "./struct_test.so".}
    
    template PrintStructValues*(testStruct: MyStruct) =
      OriginalPrintStructValues(testStruct[])
    
    var testStruct = MyStruct(
      id: 1,
      width: 2.0,
      height: 3.0,
      mipmaps: 4,
      format: 5
    )
    
    PrintStructValues(testStruct)
    

I've tested it and it works. Is there a better way of doing it?

Reply via email to