IF_ARGS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

IF_ARGS β€” picks a token for you based on whether an optional argument list is there or not ✨

Okay so real talk, this is IF_ARGS(9), straight out of the Kernel API Manual β€” section 9, bestie, we are lowkey in the grown-up part of the docs πŸ’…


🌸 SYNOPSIS 🌸

IF_ARGS (then , else , ... );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • then β€” the token you get back when the arguments are actually present 🫢
  • else β€” the token you get back when the arguments are empty, no cap 😭
  • ... β€” the arguments to check, and yes they're optional, it's giving flexible πŸ‘‘

✨ DESCRIPTION ✨

So here's the vibe: this macro lets you select a token based on whether that argument list is present or not. That's it, that's the whole flex. Presence check, token out, slay πŸ’–


πŸ”₯ EXAMPLE πŸ”₯

#define foo     X, Y
#define bar     IF_ARGS(Z, Q, foo)
#define buz     IF_ARGS(Z, Q, DROP_FIRST_ARG(FIRST_ARG(foo)))

With the definitions above, bar expands to Z while buz expands to Q. Like, look at them go, main character energy fr fr ⭐


πŸ’œ SEE ALSO πŸ’œ

Kernel file ./drivers/gpu/drm/xe/xe_args.h plus the whole squad: CALL_ARGS(9), DROP_FIRST_ARG(9), FIRST_ARG(9), LAST_ARG(9), PICK_ARG(9), ARGS_SEP_COMMA(9) β€” go read them, iykyk 🧚


ngl bestie, go check the source at ./drivers/gpu/drm/xe β€” that's where all this lives, and the page is dated October 2026 πŸŒˆπŸ’€ (yes, the future, don't ask). mwah, study up and stan the kernel πŸ“πŸ‘‘
πŸ“¦ where this page comes from