Error while building WGL code

I was compiling the code to create an opengl context using WGL. I was following the Creating_an_OpenGL_Context_(WGL) tutorial of khronos but it gives me an error which reads:

window.cpp:8:14: error: 'int WinMain' redeclared as different kind of symbol
 int WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
              ^~~~
In file included from c:\mingw\include\windows.h:44:0,
                 from window.cpp:1:
c:\mingw\include\winbase.h:1263:14: note: previous declaration 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)'
 int APIENTRY WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
              ^~~~~~~
window.cpp:8:14: error: '__in' was not declared in this scope
 int WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
              ^~~~
window.cpp:8:40: error: '__in_opt' was not declared in this scope
 int WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
                                        ^~~~~~~~
window.cpp:8:74: error: '__in_opt' was not declared in this scope
 int WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
                                                                          ^~~~~~~~
window.cpp:8:100: error: '__in' was not declared in this scope
 int WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )

I tried to solve it but couldn’t what can I do to fix it?

This isn’t an OpenGL problem, it’s a C/C++ problem and is resolvable by learning and understanding how your C/C++ environment works.

In this case your first problem is that your WinMain function signatures don’t match.

Your second problem may be because your compiler doesn’t understand the __in/etc annotations, but you haven’t actually said what compiler or version of it you’re using.

it is the latest release of mingw(gnu compiler) gcc/g++ 8.5 launched on may 14 2021

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.