Re: Weird Error
- Posted by ghaberek (admin) Apr 05, 2023
- 527 views
So while I was trying to make a simple example using my TTF_Font wrapper with my SDL wrapper. I keep getting bad routine number (1).
Error from err file C:\Euphoria\include\std\ffi.e:1011 in function c_func() c_proc/c_func: bad routine number (1)
Same issue you've encountered before: the call to define_c_func() is returning -1 meaning the function TTF_OpenFont was not found.
It looks like you're trying to open the wrong library name in SDL_ttf.e. The correct library name is SDL2_ttf.dll (note the "2").
You should really be doing some kind of unit testing or sanity checking when building these wrappers.
I might do basic sanity-checking like this, which just prints a big sequence of all the values:
-- SDL_ttf.e ? ttf & xTTF_Init & -- etc.
And then later I would do unit testing like this:
-- tests/t_sdl_ttf.e include std/unittest.e include AddOns/SDL_ttf.e set_test_abort( 1 ) -- stop testing on failure test_not_equal( "SDL2_ttf", 0, sdl2_ttf ) -- library handle test_not_equal( "TTF_Init", -1, xTTF_Init ) -- function id -- etc.
On a side note, I should probably make std/ffi.e (optionally) crash when functions or libraries are not found, or at least make it optional.
Another note: I'm sure you're using Windows, but please be mindful of file name casing for Linux compatibility.
Best practice would be to reflect the existing names. So if the file is "SDL.h" in then you should use "SDL.e" and make sure to use "include SDL.e" not "include sdl.e"
-Greg