[SDL] Attempting to make SDL wrapper for QB64 - First hurdle!

Alex Barry alex.barry at gmail.com
Mon Dec 6 13:33:02 PST 2010


Oh, I should mention that it looks like SDL_LINK_API is trying to set the
return value type to void.

Take care,
-Oz

On Mon, Dec 6, 2010 at 4:30 PM, Alex Barry <alex.barry at gmail.com> wrote:

> hey there,
> I'm happy to see that QB64 has some progress being made on it (I use
> freebasic, but I always keep track of QB64)
> Anyway, there are a few issues with your code that I'm not sure they will
> fix your error, but will help in the long run.
>
> First, use SDL_WasInit() to check to see if SDL_INIT_JOYSTICK was
> initialized/available.
>
> Next, make sure you're returning the result of the function and not the
> address of the function.
> void *address = &SDL_NumJoysticks;
> int result = SDL_NumJoysticks();
>
> I think the lack of braces is probably what's throwing your code off.
>
> On Mon, Dec 6, 2010 at 4:24 PM, Unseen Machine <jmonyon at yahoo.co.uk>wrote:
>
>>  I have Google'd myself silly trying to figure this out! Any ideas on
>> what i might be doing wrong?
>>
>> I am attemtping to make a dll that will provide access to functions for
>> QB64 that it cannot currently access. Here's my first function. It does not
>> work!
>>
>>
>>
>> Code:
>>
>>
>> SDL_LINK_API int SDL_Link_NumJoys(void)
>> {
>>    if(SDL_Init(SDL_INIT_JOYSTICK)== -1)
>>    {
>>       return -1;
>>    }
>>    else
>>    {
>>       return SDL_NumJoysticks;
>>    }
>> }
>>
>>
>>
>>
>>
>> It returns error C2440: 'return' : cannot convert from 'int (__cdecl
>> *)(void)' to 'int'
>>
>> I am using VC++2008, any help would be great. Thanks folks.
>>
>> John
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20101206/16294e3e/attachment-0008.htm>


More information about the SDL mailing list