May the compiler already know the reason for the problem? Because compiler 
refuses to do a direct cast. Cast with intermediate pointer variable works, and 
that is what is used in the cairo bindings. So the compiler may have its reason 
to refuse the direct cast, but it does not tell us its reason.
    
    
    type
      Surface00* {.pure.} = object
      Surface* = ref object
        impl*: ptr Surface00
        ignoreFinalizer*: bool
    
    when isMainModule:
      
      proc test =
        var surf = Surface()
        GC_ref(surf)
        GC_unref(cast[RootRef](surf)) # Error: expression cannot be cast to 
RootRef=ref RootObj
        var p: pointer = cast[pointer](surf)
        #GC_unref(cast[RootRef](p)) # compiles
      
      test()
    
    
    Run

Reply via email to