You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update msys2 64bit after install by running pacman -Syu if pacman needs to be updated you might have to close and reopen the terminal and run pacman -Syu again
My issue is fixed I had to replace int main with "int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow ){"
Here's my final tasks.json:
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++.exe build active file", "command": "C:\\msys64\\mingw64\\bin\\g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-I C:\\msys64\\mingw64\\include\\SDL2", "-L C:\\msys64\\mingw64\\lib", "-lmingw32", "-lSDL2main", "-lSDL2", "-lSDL2_image", "-mwindows" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "Task generated by Debugger." } ], "version": "2.0.0" }
and this is my final code:
`#include <stdio.h>
#include <windows.h>
#include <SDL2/SDL.h>
const int WIDTH = 800, HEIGHT = 600;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow ){
SDL_Window *window;
SDL_Renderer *renderer;
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
printf("SDL_Init failed: %s\n", SDL_GetError());
return 1;
}
window = SDL_CreateWindow("Hello, World!",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
WIDTH, HEIGHT,
SDL_WINDOW_ALLOW_HIGHDPI);
if(window == NULL) {
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Event event;
while(1) {
if(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT) {
break;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}`