創建一個指向SDL_Window結構體的指針並將其分配給shared_ptr時,會出現上述錯誤。類的將'sizeof'應用於不完整類型'SDL_Window'
部分:
#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,
SDL_WINDOWPOS_UNDEFINED,
window_width,
window_height,
NULL)
) == nullptr) {
std::cerr << "creating window failed: " << SDL_GetError() << std::endl;
}
window.reset(window_);
}
出現在錯誤 'window.reset()'。什麼原因以及如何解決這種行爲?
也許無關,但你不必須通過SDL_DestroyWindow,而不是刪除取消分配? – PlasmaHH