SDL_max(3)

πŸ’– SDL_max(3) β€” SDL3 FUNCTIONS πŸ’–

okay bestie, welcome to the SDL_max page, it's a short one but it's iconic, let's go ✨

🌸 NAME 🌸

SDL_max β€” return the greater of two values. that's it. that's the whole job. she picks the bigger one. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))

look at her. one line. no notes. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a helper macro, and honestly? it might be more clear than writing out the comparisons directly yourself, like, why type the whole ternary when she's right there. and she works with any type that can be compared with the > operator, so she's flexible, she's versatile, she's giving main character energy. πŸ‘‘

⚠️ BUT. and this is the important part, bestie, do NOT skip this. she double-evaluates both of her parameters. so do not use expressions with side-effects here. fr fr. if your argument does something (like i++ or a function call that changes stuff), it's gonna happen twice and you're gonna have a bad time. 😭

πŸ’… MACRO PARAMETERS πŸ’…

  • x β€” the first value to compare. πŸ“
  • y β€” the second value to compare. 🌸

⭐ RETURN VALUE ⭐

returns the greater of x and y. whoever's bigger wins, periodt. πŸ‘‘


🌈 THREAD SAFETY 🌈

it is safe to call this macro from any thread. no locking, no drama, no vibe check needed. go off. ✨


πŸ‘‘ AVAILABILITY πŸ‘‘

this macro is available since SDL 3.2.0. so if you're on something older... girl. upgrade. πŸ™ˆ


that's the whole page, you ate that. πŸ’– this little gem comes to you from the Simple Directmedia Layer crew, SDL 3.4.18, and yes she's SDL_max(3), always and forever. mwah. πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from