cofyc/argparse

Unclear and untested callback feature

mlabbe opened this issue · 1 comments

There is a callback which returns an int value. How is this handled? Does it override the value assignment for integers?

I assume the intptr_t field in options is used to pass a value to it, but that value is limited to 32-bits on x86 but 64-bits on amd64. Did you intend to make this architecture-dependent? Why not void*?

cofyc commented

argparse_callback is user-provided function. It's called when corresponding argument is parsed. What it does depends on user's implementation. Anything can be done or just print the value onto stdout.

argparse_help_cb is a builtin callback.

I choose intptr_t because it's a integer type which also can be used to hold a pointer value. Sometimes, we only need a integer to hold user-provided value, see OPT_BIT as example.