BlitzMax dll executing a C++ function pointer

BlitzMax Forums/BlitzMax Programming/BlitzMax dll executing a C++ function pointer

JoshK(Posted 2008) [#1]
Since C++ can't access BlitzMax lists, here is my function to iterate through all entities in the world. What would the C++ end of this look like?
Function dll_ForEachEntityDo(func:Byte Ptr) "win32"
    Local entity:TEntity
    Local callback:Int(hentity:Int) "win32"
    callback=func
    For entity=EachIn currentworld().entities
        If callback(entity.handle)=0 Return
    Next
EndFunction



Azathoth(Posted 2008) [#2]
I'm not sure what you want your callback to do, or how you're loading the DLL (load-time or run-time), but since your blitzmax code is calling the callback using the stdcall convention you need to declare your C++ function with __stdcall or whatever your compiler uses.