Let's say I provide the following long option arguments structure:
static const struct option long_opts[] = {
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
};
How can I specify an additional option, named '--myoption', but without the short form? So I would be able to call only:
./binary --myoption
I need this because I ran out of letters.
If you don't put that option into shortopts
then no short option for that parameter will be used. E.g.:
#define MYOPT 1000
static struct option long_options[] = {
{"myopt", no_argument, 0, MYOPT },
}
[...]
c = getopt_long(argc, argv, "", long_options, &option_index);
switch (c) {
case MYOPT:
/* Do stuff. */
break;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With