创建指向SDL_Window结构的指针并将其分配给shared_ptr,会产生上述错误.
课程的一部分:
#include <SDL2/SDL.h> class Application { static std::shared_ptr<SDL_Window> window; }
定义:
#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,window_width,window_height,NULL) ) == nullptr) { std::cerr << "creating window Failed: " << SDL_GetError() << std::endl; } window.reset(window_); }