As seen on this issue here I had a few errors while trying to create a window, which are now fixed with this code:
#include <stdio.h>
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_video.h>
int main() {
int SDL_Window;
SDL_Window * SDL_CreateWindow("title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 720, 480, 0);
}
However, there’s a new error now:
main.c: In function 'main':
main.c:9:20: error: invalid operands to binary * (have 'int' and 'SDL_Window *')
9 | SDL_Window * SDL_CreateWindow("title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 720, 480, 0);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| SDL_Window *
replacing the last line by SDL_Window = SDL_CreateWindow("title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 720, 480, 0);
doesen’t trigger an error anymore, but it does give me a warning:
main.c: In function 'main':
main.c:9:20: warning: assignment to 'int' from 'SDL_Window *' makes integer from pointer without a cast [-Wint-conversion]
9 | SDL_Window = SDL_CreateWindow("title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 720, 480, 0);
| ^
Nontheless,when running the executable a window does appear, but then instantly crash, i’m not sure if this is intended or not since there’s nothing after interacting with the window, but a warning is probably not a good sign.
I figured it might have something to do with pointers, but I am way too much of a beginner to understand what causes this.
Minignoux is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.