我想在头文件中转发声明一个结构体。
struct GLFWvidmode;
class DesktopVideoMode {
private:
const GLFWvidmode *videomode;
public:
DesktopVideoMode(const GLFWvidmode *videomode);
...
在 cpp 文件中,我包含带有定义的外部标头...
#include "DesktopVideoMode.hpp"
#include <GLFW/glfw3.h>
...错误在哪里“使用不同类型的 Typedef 重新定义('struct GLFWvidmode' 与 'GLFWvidmode')“ 发生:
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;
像这种情况我就不能转发申报吗?
GLFWvidmode
不是一个结构,它是一个 typedef。您不能前向声明 typedef。无论谁选择使用未命名的结构,都做出了糟糕的设计决策。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)