IF_ARGS(9)
π 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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms