@@ -16,7 +16,7 @@ See example.c for usage. Most of the OPTTYPES should be self-explanatory. Do
note that in the case of OPTTYPE_BOOL, simply receiving the flag constitutes
being enabled, so if you want to do something like "--dox yes", you will have to
pass an OPTTYPE_STRING and do a strcmp yourself. The library is written in ansi
-c89, so it should work *pretty much* anywhere.
+c99, so it should work *pretty much* anywhere.
The function takes pointers to argc and argv because it modifies them. It
removes all the flags, leaving only the arguments. argv[0] is untouched, and
#include <stdbool.h>
int main(int argc, char **argv) {
- int debug = false;
+ bool debug = false;
char *name = NULL;
float boat = 0.0;
@@ -52,11 +52,8 @@ static int get_option_index_long(char *opt, char **potentialopts, uint len) {
}
-signed char fetchopts(int *argc, char ***argv, struct opttype *opts) {
+void fetchopts(int *argc, char ***argv, struct opttype *opts) {
uint numopts = countopts(opts);
- if (!numopts) {
- return 0;
- }
char *longopts[numopts];
char shortopts[numopts];
/* -1, because argv starts at 1 (with 0 as program name), but newargv starts at 0 */
(*argv)[i] = newargv[i-1];
}
-
- return 1;
}
@@ -20,4 +20,4 @@ struct opttype {
#define OPTTYPE_LONGDOUBLE 13
#define OPTTYPE_STRING 14
-signed char fetchopts(int *argc, char ***argv, struct opttype *opts);
+void fetchopts(int *argc, char ***argv, struct opttype *opts);