Closing Game Controller

Hello,

In my GameController class I know that to close an SDL_GameController it is: SDL_GameControllerClose(SDL_GameController *gamecontroller)

Does this handle the game controller pointer? I have a member variable SDL_GameController in my class, do I call SDL_GameControllerClose() on it and also delete the pointer in the class destructor, or is that redundant? Currently I am doing this, but get the compiler warning:

“warning C4150: deletion of pointer to incomplete type ‘_SDL_GameController’; no destructor called” VS2012.

Thanks

  1. You would NOT call delete, you would call free(). delete is for
    memory allocated via new in C++, free is for memory allocated via
    malloc. SDL is C based and you would never call delete with pointers
    from it.

  2. SDL owns all of its pointers, if you got the pointer from an sdl
    function (like SDL_GameControllerOpen) then an sdl function is
    designed to free the memory (like SDL_GameControllerClose).On Sun, Mar 23, 2014 at 1:00 PM, Martin Grant wrote:

Hello,

In my GameController class I know that to close an SDL_GameController it is:
SDL_GameControllerClose(SDL_GameController *gamecontroller)

Does this handle the game controller pointer? I have a member variable
SDL_GameController in my class, do I call SDL_GameControllerClose() on it
and also delete the pointer in the class destructor, or is that redundant?
Currently I am doing this, but get the compiler warning:

“warning C4150: deletion of pointer to incomplete type
‘_SDL_GameController’; no destructor called” VS2012.

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks for the quick reply, good information there thanks!> Date: Sun, 23 Mar 2014 13:08:20 -0400

From: andre at andred.ca
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Closing Game Controller

  1. You would NOT call delete, you would call free(). delete is for
    memory allocated via new in C++, free is for memory allocated via
    malloc. SDL is C based and you would never call delete with pointers
    from it.

  2. SDL owns all of its pointers, if you got the pointer from an sdl
    function (like SDL_GameControllerOpen) then an sdl function is
    designed to free the memory (like SDL_GameControllerClose).

On Sun, Mar 23, 2014 at 1:00 PM, Martin Grant <@Martin_Grant> wrote:

Hello,

In my GameController class I know that to close an SDL_GameController it is:
SDL_GameControllerClose(SDL_GameController *gamecontroller)

Does this handle the game controller pointer? I have a member variable
SDL_GameController in my class, do I call SDL_GameControllerClose() on it
and also delete the pointer in the class destructor, or is that redundant?
Currently I am doing this, but get the compiler warning:

“warning C4150: deletion of pointer to incomplete type
‘_SDL_GameController’; no destructor called” VS2012.

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org