On Wed, Aug 09, 2023 at 12:07:07PM -0700, Junio C Hamano wrote: > But I am failing to imagine how the calling side actually would look > like. Can we do something along the lines of > > #define OPT_CALLBACK(s, l, v, a, h, cb) > .short_name = (s), > .long_name = (l), > .value_ ## typeof(v) = &v, > .help = (h), > .callback = (cb), > > with a clever CPP trick? It sounds like either too much churn or > too much magic or both, at least to me. Sadly, I think "typeof" is not sufficiently portable, and there is no replacement. You'd have to do something like: int my_foo; ... OPT_CALLBACK('f', "foo", int, &my_foo, ...etc); Not great, but it might not be _too_ bad given that most helpers like OPT_BOOL() can just say "int" behind the scenes. That said, I don't recall these void pointers being a large source of errors in the past. So while it's a fun type-system puzzle, the effort/reward ratio might not be favorable. -Peff