END_OF_MAIN(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– END_OF_MAIN πŸ’–

ok so this is a page from the Allegro manual β€” the Allegro game programming library manual, section 3 β€” and it's all about one tiny lil macro called END_OF_MAIN. she's small but she's doing the MOST. πŸŽ€


✨ NAME ✨

END_OF_MAIN β€” the macro you put right after your main() function, bestie. literally that's her whole job. Allegro game programming library core. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <allegro.h>

Macro END_OF_MAIN()

that's it. that's the whole thing. no args, no nothing. she just exists at the end of your file. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

ok so here's the tea, and it's actually important so listen up 🫢

to keep everything cross-platform compatible, you have to put this macro at the very end of your main function. like, the actual end. not in the middle, not before your closing brace situation β€” the end end.

the way this works is she uses some 'magic' ✨ to mangle your main procedure on the platforms that need it, like:

  • Windows
  • some flavours of UNIX
  • MacOS X

basically the platforms that are picky about this stuff. πŸ’€

and here's the slay part: on the other platforms β€” the chill ones β€” this macro compiles to nothing. literally nothing. zero. so you do not have to #ifdef around it, and honestly thank god, because nobody wants to be writing preprocessor guards around a single macro at 3am. πŸ™ˆ


🌈 Example 🌈

int main(void)
{
   allegro_init();
   /* more stuff goes here */
   ...
   return 0;
}
END_OF_MAIN()

see how she's sitting outside the closing brace? yeah. that's the vibe. main character energy fr fr. πŸ”₯

⚠️ ngl bestie if you forget her, the platforms that need the mangling are gonna be so dramatic about it. just always drop END_OF_MAIN() after your main and you're golden. πŸ’–

πŸ’œ SEE ALSO πŸ’œ

  • Allegro β€” the whole library, the moment, the icon πŸ‘‘

and that's the page!! short, sweet, absolutely iconic, no notes. πŸ“

this was Allegro, version 4.4.3, serving END_OF_MAIN(3) realness, and that's the sign-off bestie β€” go put that macro at the end of your main and slay πŸ’…βœ¨πŸ§š

πŸ“¦ where this page comes from