Struct forward declaration error: Typedef redefinition with different types
c++, forward-declaration, struct
Solution
`GLFWvidmode` is not a struct, it's a typedef. You can't forward-declare a typedef. Whoever chose to use an unnamed struct made a poor design decision.
Problem
I want to forward declare a struct in the header file. ``` struct GLFWvidmode; class DesktopVideoMode { private: const GLFWvidmode *videomode; public: DesktopVideoMode(const GLFWvidmode *videomode); ... ``` In the cpp file I include the external header with the definition... ``` #include "DesktopVideoMode.hpp" #include <GLFW/glfw3.h> ``` ...where the error "Typedef redefinition with different types ('struct GLFWvidmode' vs 'GLFWvidmode')" happens: ``` typedef struct { /*! The width, in screen coordinates, of the video mode. */ int width; /*! The height, in screen coordinates, of the video mode. */ int height; /*! The bit depth of the red channel of the video mode. */ int redBits; /*! The bit depth of the green channel of the video mode. */ int greenBits; /*! The bit depth of the blue channel of the video mode. */ int blueBits; /*! The refresh rate, in Hz, of the video mode. */ int refreshRate; } GLFWvidmode; ``` Can't I forward declare in a case like this?