我想转发在头文件中声明结构。结构向前声明错误:使用不同类型的Typedef重新定义
struct GLFWvidmode;
class DesktopVideoMode {
private:
const GLFWvidmode *videomode;
public:
DesktopVideoMode(const GLFWvidmode *videomode);
...
在CPP文件I包括与定义的外部报头...
#include "DesktopVideoMode.hpp"
#include <GLFW/glfw3.h>
...其中误差“重新定义的typedef具有不同类型( '结构GLFWvidmode' VS“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;
我不能在这样的情况下转发声明吗?
是的,我意识到后,我发表了评论,并从此抹去。 – Anycorn
@AdamS:那么你不能避免包括头... –