Although I've seen many questions referring to the "Incomplete type not allowed" error in C++, I still cannot figure out what the compiler is trying to tell me when it screams at me like this. I've been able to piece together that it has something to do with #include
-ing header files, but I am clueless as to what an "incomplete type" is and why it is "not allowed". I got the error when trying to inherit from SDL_Window
as such:
#pragma once
#include "SDL.h"
class Window : public SDL_Window
{
public:
Window();
~Window();
};
Could someone please explain to me what the error means, how to (generally) fix it, and, in my case, what I should do to stop it from happening?
C++ - What does “Incomplete type not allowed” error mean
Incomplete type means that there is no definition for the type SDL_Window
.
The error means that the type is incomplete, and that an incomplete type wasn't allowed in that context. In this particular case: an incomplete type cannot be used as a base class.
what I should do to stop it from happening?
Do not attempt to use SDL_Window
as a base class - it is not intended to be used in that way.
SDL_Window
is intended to be used as an opaque pointer. Some SDL functions may return you a SDL_Window*
. You can store it, and send it as an argument to other SDL functions. That is all it is used for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With