Après avoir initialiser la SDL, j'ai constaté que la variable errno a pris la valeur 11 signifiant que la ressource est indisponible. J'aimerais savoir comment corriger ce problème.
#include <stdio.h>
#include <stdlib.h>
#include "../includes/init.h"
#include "../includes/map.h"
#include "../includes/startGame.h"
#include <errno.h>
int main(int argc, char const *argv[]){
int game = 1;
SDL_Window* screen = NULL;
SDL_Renderer *screen_render = NULL;
SDL_Event e;
initAllScreenAndRenderer(&screen, &screen_render);
while (game){
while (SDL_PollEvent(&e)){
switch (e.type){
case SDL_QUIT:
game=0;
break;
case SDL_KEYDOWN:
switch (e.key.keysym.sym){
case SDLK_a:
play(&screen_render);
break;
}
break;
}
}
SDL_RenderClear(screen_render);
SDL_RenderPresent(screen_render);
}
destroyAllScreenAndRenderer(&screen, &screen_render);
}
void initAllScreenAndRenderer(SDL_Window **window, SDL_Renderer **window_renderer){
printf("\n%d\n", errno);
if (SDL_Init(SDL_INIT_VIDEO) == -1 || IMG_Init(IMG_INIT_PNG) != IMG_INIT_PNG){
printf("\nError of initialisation : %s\n", SDL_GetError());
exit(-1);
}
printf("\n%d\n", errno);
*window = SDL_CreateWindow(GAME_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGTH, SDL_WINDOW_SHOWN);
if (*window==NULL){
printf("\nError of initialisation window : %s\n", SDL_GetError());
exit(-1);
}
printf("\n%d\n", errno);
*window_renderer = SDL_CreateRenderer(*window, -1, SDL_RENDERER_ACCELERATED);
if (*window_renderer==NULL){
printf("\nError of initialisation renderer : %s\n", SDL_GetError());
exit(-1);
}
printf("\n%d\n", errno);
}
La SDL n'utilise pas errno. Si tu veux voir une erreur de SDL il faut utiliser SDL_GetError. La valeur que tu affiches peut venir de n'importe quoi que SDL a appelé en interne (car tôt ou tard, SDL fera des appels systèmes et/ou POSIX).
- Edité par markand 24 février 2022 à 8:51:06
git is great because Linus did it, mercurial is better because he didn't.
Code 11 de errno apres initialisation de SDL
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
git is great because Linus did it, mercurial is better because he didn't.