SDL2: Translate "const Uint8*" from c to fb?

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

SDL2: Translate "const Uint8*" from c to fb?

Post by h4tt3n »

Hello folks,

Quick question. I am translating a SDL2 tutorial series from c/cpp to fb, and after having translated the first many examples without any trouble I ran into this peculiar problem.

I need to translate this line:

Code: Select all

const Uint8* keys = SDL_GetKeyboardState( NULL );
to freebasic dialect, which should be pretty straight forward:

Code: Select all

Const As Uint8 Ptr keys = SDL_GetKeyboardState( NULL )
It returns a pointer to an array of key states. But the compiler keeps throwing an "error 11: Expected constant". With the SDL library included Uint8 is a valid variable.

According to the official SDL2 Wiki I should be doing it just about right, but clearly I am not.

Thanks in advance!

Cheers, Mike
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: SDL2: Translate "const Uint8*" from c to fb?

Post by fxm »

dkl wrote:When declaring a constant (with Const at the beginning) it must be a compile-time constant. Only variables declared with Dim or Var at the beginning can allow "run-time constants" like the address of a string literal.
Try perhaps with:
Dim As Const Uint8 Const Ptr keys = SDL_GetKeyboardState( NULL )
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: SDL2: Translate "const Uint8*" from c to fb?

Post by h4tt3n »

Thanks fxm, that did the trick!

I will be posting the SDL2 tutorials and samples when I'm finished, but it may take a little while yet.
Post Reply