BytePtr to string

BlitzMax Forums/BlitzMax Programming/BytePtr to string

With v1.10, in my module, I wrote:
'extern
Load(filename:Byte Ptr)
end extern '

Now, with 1.12, the BMX say me
'cannot convert string to byte ptr'
How to make now to pass in parameter a string for an external function

...I'm not here...Roight...

Load("filename".ToCString())


thank's and excz me for dble post.... :(

...but it is not very elegant...

there was some discussion that due to the new GC, doing ToCString() to pass to extern functions could potentially cause issues. i believe the issue was taken into consideration and is automatically handled when you use $z (i think $z is undocumented) instead of the Byte Ptr/ToCString() combination. so your above declaration would change to:

extern
Load(filename$z) 
end extern

and then you just pass the string. no need for .ToCString(). i havent tested it yet, but i think there is a $w as well for .ToWString().

EDIT: i dont think $w made it into the build...

Thank you very much.
I test and I look at how that functions.

Some of these strange things should really have been documented. Age old tale, I know.

...@#!*...

Oops...I forgot that 'cstrings' aren't cleaned up by the GC any more.

So much new stuff to take in with this release. :o/