Skip to content

Commit 19800bd

Browse files
rscharfegitster
authored andcommitted
parseopt: move definition of enum parse_opt_result up
Define enum parse_opt_result before using it in a typedef. This avoids the following compiler warning: ./parse-options.h:53:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic] typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx, ^ While GCC and Clang both accept such a forward reference by default, other compilers might be less forgiving. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7e68a0 commit 19800bd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

parse-options.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ enum parse_opt_option_flags {
4545
PARSE_OPT_COMP_ARG = 1024
4646
};
4747

48+
enum parse_opt_result {
49+
PARSE_OPT_COMPLETE = -3,
50+
PARSE_OPT_HELP = -2,
51+
PARSE_OPT_ERROR = -1, /* must be the same as error() */
52+
PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
53+
PARSE_OPT_NON_OPTION,
54+
PARSE_OPT_UNKNOWN
55+
};
56+
4857
struct option;
4958
typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
5059

@@ -224,15 +233,6 @@ const char *optname(const struct option *opt, int flags);
224233

225234
/*----- incremental advanced APIs -----*/
226235

227-
enum parse_opt_result {
228-
PARSE_OPT_COMPLETE = -3,
229-
PARSE_OPT_HELP = -2,
230-
PARSE_OPT_ERROR = -1, /* must be the same as error() */
231-
PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */
232-
PARSE_OPT_NON_OPTION,
233-
PARSE_OPT_UNKNOWN
234-
};
235-
236236
/*
237237
* It's okay for the caller to consume argv/argc in the usual way.
238238
* Other fields of that structure are private to parse-options and should not

0 commit comments

Comments
 (0)