Nimrod comes with some nice wrappers for th iup GUI library. IUP is nice but has an ugly hack that uses the same prototype for callback pointers, but the callbacks are called in anoteher way. This is allowed i C but i just cant get it to work in nimrod. See the captial comment in the middle of the attached code. How can i change this program to compile?
By the way, what's the default calling convention in nimrod? cdecl? why do iup callback have to have the .cdecl. pragma if thats the case?
import iup
proc click(ih:PIhandle):cint {.cdecl.}=
return IUP_DEFAULT
proc button_cb(ih:PIhandle,button,pressed,x,y:cint,status:cstring):cint {.cdecl.}=
setAttribute(ih,"TITLE","button_cb")
return IUP_DEFAULT
discard iup.open(nil,nil)
var btn=iup.button("Hello!",nil)
discard setCallback(btn,"ACTION",click)
#THIS IS THE PROBLEM LINE THAT DONT COMPILE
#BECAUSE BUTTON_CB HAS THE WRONG PROTO:
discard setCallback(btn,"BUTTON_CB",button_cb)
setAttribute(btn,"RASTERSIZE","200x200")
var d=iup.dialog(btn)
discard d.show()
discard mainloop()
discard setCallback(btn,"BUTTON_CB", cast[ICallback](button_cb))