Byte Ptr Ptr(VarPtr(String)) same as char ** ?

BlitzMax Forums/BlitzMax Programming/Byte Ptr Ptr(VarPtr(String)) same as char ** ?

AndrewT(Posted 2010) [#1]
I'm working with OGL right now, and glShaderSource requires that one of its parameters is a const char **, aka an array of char *. I only have one string, so I'm essentially trying to pass a pointer to the string, or, since the string itself is a pointer, I'm trying to pass a pointer to a pointer to the string. What I've come up with is to do this

Byte Ptr Ptr(VarPtr(MyString))

Is this the way one would typically pass a string as a char **?The biggest reason for which I ask is that my shaders aren't working :P but I'll be posting about that in the OpenGL forum. I just want to make sure that I can cross incorrect casting off of the list of possible sources of error.


N(Posted 2010) [#2]
You should probably be using something like
Local cstr@Ptr = someString.ToCString()

' Do something with the C string.

MemFree(cstr) ' You have to do this.


The problem with what you're doing is that String, in BlitzMax, is not just an alias for char*. It's also not multibyte internally, which is what you seem to be looking for, so passing a pointer to the data part of the string object also won't work. Strings are objects, just like arrays and anything else that is derived from Object (basically everything other than basic data types).


AndrewT(Posted 2010) [#3]
Ahh, I didn't even know I could retrieve a c-string. Thanks!

Oh, and I'm not familiar with the syntax you used when declaring the string--is @Ptr just another way of saying Byte Ptr, or is there some significance to it that I'm missing?


plash(Posted 2010) [#4]
@Ptr is a Byte Ptr.


AndrewT(Posted 2010) [#5]
Thanks.