Creating a pointer to the SDL_Window structure and assigning it to shared_ptr, the errors mentioned.
Part of the class:
#include <SDL2/SDL.h> class Application { static std::shared_ptr<SDL_Window> window; }
Definition:
#include "Application.h" std::shared_ptr<SDL_Window> Application::window{}; bool Application::init() { SDL_Window *window_ = nullptr; if((window_ = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, NULL) ) == nullptr) { std::cerr << "creating window failed: " << SDL_GetError() << std::endl; } window.reset(window_); }
The error appears in the window.reset () window. What is the reason and how to fix this behavior?
source share