I am using GLFW for handling window events in an application. It works fine. Later I decide to remove raw pointers starting from GLFWwindow. It defined in the file glfw3.h as:
typedef struct GLFWwindow GLFWwindow;
And I cannot find the actual definition of the structure in the header file. So I assume this is a kind of forward declaration, but I have no idea why it is not like
struct GLWwindow;
I tried to use the later form of forward declaration to replace the former form. It compiles fine. What is the pro of the former formation of forward declaration?
So the real questions, since the structure GLFWwindow is only a declaration, unique pointer can not complete template specialization without definition. I can not use unique_ptr to declare any pointer. The compiler gives me error
C2027 use of undefined type 'GLFWwindow'
C2338 can't delete an incomplete type
C4150 deletion of pointer to incomplete type 'GLFWwindow';no destructor called
Anyone knows how to use unique pointer with GLFWwindow?
typedef struct GLFWwindow GLFWwindow;
this is for C. In C you need a typedef if you don't want to writestruct GLFWwindow
every time you need this type. – Similar