BytePtr to string

BlitzMax Forums/BlitzMax Programming/BytePtr to string

TMyke(Posted 2005) [#1]
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


Yan(Posted 2005) [#2]
...I'm not here...Roight...


Yan(Posted 2005) [#3]
Load("filename".ToCString())



TMyke(Posted 2005) [#4]
thank's and excz me for dble post.... :(

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


gman(Posted 2005) [#5]
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...


TMyke(Posted 2005) [#6]
Thank you very much.
I test and I look at how that functions.


Hotcakes(Posted 2005) [#7]
Some of these strange things should really have been documented. Age old tale, I know.


Yan(Posted 2005) [#8]
...@#!*...


Yan(Posted 2005) [#9]
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/