Using callbacks in a DLL

BlitzMax Forums/BlitzMax Programming/Using callbacks in a DLL

I am running one BlitzMax program and calling a DLL written in BlitzMax with it.

I am experiencing some random variable changes, which only happen when I have an error in a dll. It usually happens when I forget to add GCEnter() at the start of a dll function, or when I forget to add "win32" to the end of the function declaration.

However, this is now happening when I use my callback function. The function accepts a function pointer, then calls that function for every object in the list:
Function dll_ForEachTextureGroupDo(fn:Byte Ptr) "win32"
	GCEnter()
	Local callback:Int(handle:Int)
	callback=fn
	For texturegroup:TTextureGroup=EachIn TTextureGroup.list
		If Not callback(texturegroup.handle) Exit
	Next
EndFunction


The callback looks like this. (This is a part of the main program):
Function Callback:Int(handle:Int)
	Return True
EndFunction


So the main program sends the function pointer to the dll, and the dll performs the function for all objects in a list.

And the program is actually going like this:
EXE stuff
	DLL stuff
		EXE stuff
	DLL stuff
EXE stuff


Do I need to add GCLeave() or do anything extra like that before the dll calls the callback?