A couple of questions about SDL_Window and unique_ptr

I am currently having a problem saving the SDL_Window pointer as std :: unique_ptr.
I have tried:

std::unique_ptr<SDL_Window> window_;

Decision:

std::unique_ptr<SDL_Window, void(*)(SDL_Window*)> window_;

The first attempt continued to throw errors in the memory header, saying that SDL_Window is an incomplete type. Well, I know that SDL_Window is a structure and cannot be called using

SDL_Window* window_ = new SDL_Window();

therefore, initialization is done using SDL_CreateWindow (params).

Questions :

  • Why can't I call the default constructor (or any other) for SDL_Window?
  • Why unique_ptr needs deleter in this case, but not here:

    renderSystem_ = std::unique_ptr<Renderer::RenderSystem>(new Renderer::RenderSystem());
    

    RenderSystem - , .
    , unique_ptr , deleter ?

!

+4
1

SDL_Window, , .

SDL C: .

, , SDL_Window :

struct SDL_Window;

.

, , SDL_Window - , . , , , , - .

SDL_Window, :

struct SDLWindowDestroyer
{
    void operator()(SDL_Window* w) const
    {
        SDL_DestroyWindow(w);
    }
};

std::unique_ptr<SDL_Window, SDLWindowDestroyer> window_;

window_

+2

All Articles