Passing Function ( with params ) to C++ code.

BlitzMax Forums/BlitzMax Programming/Passing Function ( with params ) to C++ code.

Gabriel(Posted 2006) [#1]
I want to pass a BlitzMax function ( which takes several parameters and returns another ) to a CPP function.

The callback function I pass looks like this :

Function WinProc(hWnd:Int,Msg:Int,wParam:Int,lParam:Int)


But I'm not entirely sure how the BMax Extern "C" declaration should look, nor how the CPP function which receives it should look.


N(Posted 2006) [#2]
Function WinProc( hwnd%, wparam%, lparam% )
    Print "blah -- doing just this in a WndProc/WinProc function may crash the program, but the correct functionality of the Proc functions is beyond the scope of this example"
End Function

Extern "C"
  Function passCallback( someCallback:Int(h%,w%,l%) )
End Extern

passCallback( WinProc )



Gabriel(Posted 2006) [#3]
Hmm, could have sworn that's how I had it before. It works now anyway, so thanks for that Noel. No worries about the contents of the function. I know what has to be done within a WinProc callback. At least I think I do, lol.

This is the last major hurdle with the TV3D wrapper. Once I have the window creation working, I should be able to get a test app running.