r/C_Programming • • 4d ago

C's designated initializers give us named arguments – Arthur O'Dwyer

https://quuxplusone.github.io/blog/2026/11/16/named-arguments-in-c/
48 Upvotes

4 comments sorted by

4

u/zhivago 2d ago

Yeah, and you don't even need the macros.

ideal_volume((IdealVolumeArgs){ .kelvin = 373.15 }));

Of course, it would be nice if you could just write ideal_volume({ .kelvin = 373.15 }), but you can review the many proposals to allow this and see why they've been rejected over the years.

1

u/tstanisl 1d ago

One can always do:

#define ideal_volume(...) \
  ideal_volume((IdealVolumeArgs) __VA_ARGS__)

0

u/[deleted] 3d ago

[removed] — view removed comment

2

u/C_Programming-ModTeam 3d ago

Rude or uncivil comments will be removed. If you disagree with a comment, disagree with the content of it, don't attack the person. Provide your reasoning, not just a judgement.