Clever, but seems like a solution in a search of a problem.
The solution is named arguments, but I'm not convinced the added complexity of this solution is a net improvement.
C is like that really. You really need to pay attention to detail when you're writing C. And if there's too much to worry about, it means you need to redesign and simplify the APIs and/or data you're dealing with.
If I encounter functions with lots of parameters in third party libraries I have to use, I will annotate each argument with a comment (after checking the documentation).
OVERKILL_TYPEDEF_PTR_T somefunc(TYPE1_T, TYPE2_PTR_T, void *);
I always document my functions in the headers, especially for private code only I will use. E.g. /*
* Like vfprintf(), but prepends a timestamp and the name of the current thread
* or process. The output FILE will be locked using lockf() while the
* timestamp, thread name, and message are written. The thread name can be set
* using set_threadname().
*/
int vfptmf(FILE *out, const char *format, va_list args);Given:
int price, quantity;
compare place_order(price, quantity);
with {
price_t px = { price };
quantity_t qx = { quantity };
place_order(qx, px);
}
More verbose (especially where, like above, the values weren't already wrapped), but catches a significant error.It does not permit reordering arguments like the struct approach does, and doesn't help where you have multiple arguments of the same type that it is unreasonable to distinguish.