Converting and using const char * strings.

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
SMC
Posts: 33
Joined: Feb 22, 2012 4:05

Converting and using const char * strings.

Post by SMC »

I guess what I would really like to know is if this is working right.

Code: Select all

''Create a texture
Var bitmap = SDL_LoadBMP("square.bmp")
If bitmap = 0 Then 
    Print #EF, "SDL_LoadBMP() failed "; SDL_GetError() 
    End
End If
I'm asking because with freebasic I get this written to my error file:

Code: Select all

SDL_LoadBMP() failed 334301808
Instead of this (c version):

Code: Select all

SDL_LoadBMP failed : : Parameter 'src' is invalid 
Ignore the extra : I added that.

For the record, "square.bmp" is a nonexistent file. That's why it's throwing the error. Everything works when I give it a valid filename, I'm just trying to understand why the error messages are different. Originally I tried this:

Code: Select all

Print #EF, "SDL_LoadBMP() failed " + SDL_GetError() 
But freebasic didn't like it. Is zstring conversion not automatic?
RetardedAndProud
Posts: 35
Joined: Jun 09, 2024 18:26

Re: Converting and using const char * strings.

Post by RetardedAndProud »

Dereference SDL_GetError()...

Code: Select all

Print #EF, "SDL_LoadBMP() failed "; *SDL_GetError()
SMC
Posts: 33
Joined: Feb 22, 2012 4:05

Re: Converting and using const char * strings.

Post by SMC »

RetardedAndProud wrote: May 22, 2025 19:06 Dereference SDL_GetError()...

Code: Select all

Print #EF, "SDL_LoadBMP() failed "; *SDL_GetError()
That works, thanks.
Post Reply