allegro_error(3alleg4)

✨ allegro_error ✨

okay so bestie, you're in the Allegro manual, section 3alleg4, and today's main character is allegro_error β€” she's the one who stores the last Allegro error message. πŸ’…


🌸 NAME 🌸

allegro_error β€” stores the last Allegro error message.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

extern char allegro_error[ALLEGRO_ERROR_SIZE];

πŸ’– DESCRIPTION πŸ’–

So this is a text string, right? And the way that set_gfx_mode(), install_sound() and other functions use it is literally just to report error messages. So when they fail and you actually want to tell the user why everything is giving chaos, this is the place to look for a description of the problem. no cap. 🫢

Example, because seeing it is believing:

void abort_on_error(const char *message)
{
   if (screen != NULL)
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

   allegro_message("%s.\nLast Allegro error `%s'\n",
                   message, allegro_error);
   exit(-1);
}
...
   if (some_allegro_function() == ERROR_CODE)
      abort_on_error("Error calling some function!");

iconic behaviour fr fr 😭


πŸ‘‘ SEE ALSO πŸ‘‘


k bye bestie, go read your error messages, they're lowkey trying to tell you something πŸ’œ

this page came to you courtesy of Allegro, version 4.4.3, filed under allegro_error(3alleg4) β€” slay, mwah πŸŽ€βœ¨