C++ dll and blitzmax

BlitzMax Forums/BlitzMax Programming/C++ dll and blitzmax

If you are calling from BlitzMax, you can either pass the String directly or first convert it to a CString.

A pseudo example...
Extern

  Function somedll_func(constcharstar:Byte Ptr)

End Extern

Local myString:String = "Hallo!"

somedll_func(myString)

Local s:Byte Ptr = myString.ToCString()

somedll_func(s)

MemFree(s)


Both are known to work. You just need to be careful if the string data needs to be around for longer than the call to the function. (eg. the function doesn't copy the string and uses the pointer to it, for use later).

:-)