DEV Community

Cover image for Default parameters in C

Default parameters in C

Remo Dentato on January 08, 2021

Variadic functions Modern languages (like Python or Javascript) have a nice feature: they allow a function to have a variable number of ...
Collapse
 
dynamicsquid profile image
DynamicSquid

I love how C doesn't have any "modern" features, but C devs are like screw it, we'll figure out a way ourselves

Collapse
 
seanlumly profile image
Sean Lumly

Neat!

I like the argument counting. It is quite a clever use of the variadic macro, effectively "pushing" the argument count value into range with the number of arguments. I've not seen this before, nor considered it.

I was never a fan of variadic functions either, and this gets me thinking of other creative ways to mimic the behaviour.

Collapse
 
basketcree profile image
basketcree

It's really astonishing way to using "default parameters" in c.
i love way you do it.