Just working on a small project using SDL2...
System info: Windows
App info: using C (pure C, no c++), mingw-x64 & SDL2.
Now;
Firstly, SDL.h
requires the main
function to be renamed as WinMain
.
On the other hand, when getting the screen resolution, I tended to use the GetSystemMetrics
function, which requires windows.h
to be included in the pre-processor section and at this point, WinMain
in my code conflicts with WinMain
declared previously in winbase.h
. When I'm using both (SDL.h
and windows.h
), compiler responds:
previous declaration of 'WinMain' was here:
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
That's because, WinMain
is declared somewhere in the winbase.h
, which is auto-included via windows.h
.
Is there a way to get the screen resolution w/o using GetSystemMetrics
/ windows.h
? Any other ideas?
Ok! I've realized what I was doing wrong...
For the linking phase, I was using the following libraries and the linker was complaining about the WinMain
function not to be found.
-lSDL2main
-lSDL2
Then I added the mingw32 library as shown below and the problem got solved (the order of the libraries does matter I think).
-lmingw32
-lSDL2main
-lSDL2