{"thread":{"id":"51694","subject":"[PATCH] parseopt: move definition of enum parse_opt_result up","startedAt":"2019-08-20T18:49:16Z","lastAt":"2019-08-22T14:47:09Z","messageCount":2,"participants":["René Scharfe","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"380836","messageId":"58e5dd7b-d577-a1d9-c704-44642f553323@web.de","threadId":"51694","inReplyTo":null,"subject":"[PATCH] parseopt: move definition of enum parse_opt_result up","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-08-20T18:49:07Z","receivedAt":"2019-08-20T18:49:16Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Define enum parse_opt_result before using it in a typedef.  This avoids\nthe following compiler warning:\n\n   ./parse-options.h:53:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]\n   typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n                ^\n\nWhile GCC and Clang both accept such a forward reference by default,\nother compilers might be less forgiving.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n parse-options.h | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex a4bd40bb6a..38a33a087e 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -46,6 +46,15 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_COMP_ARG = 1024\n };\n\n+enum parse_opt_result {\n+\tPARSE_OPT_COMPLETE = -3,\n+\tPARSE_OPT_HELP = -2,\n+\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n+\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n+\tPARSE_OPT_NON_OPTION,\n+\tPARSE_OPT_UNKNOWN\n+};\n+\n struct option;\n typedef int parse_opt_cb(const struct option *, const char *arg, int unset);\n\n@@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);\n\n /*----- incremental advanced APIs -----*/\n\n-enum parse_opt_result {\n-\tPARSE_OPT_COMPLETE = -3,\n-\tPARSE_OPT_HELP = -2,\n-\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n-\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n-\tPARSE_OPT_NON_OPTION,\n-\tPARSE_OPT_UNKNOWN\n-};\n-\n /*\n  * It's okay for the caller to consume argv/argc in the usual way.\n  * Other fields of that structure are private to parse-options and should not\n--\n2.23.0\n"},{"id":"380936","messageId":"nycvar.QRO.7.76.6.1908221646460.46@tvgsbejvaqbjf.bet","threadId":"51694","inReplyTo":"58e5dd7b-d577-a1d9-c704-44642f553323@web.de","subject":"Re: [PATCH] parseopt: move definition of enum parse_opt_result up","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-22T14:47:01Z","receivedAt":"2019-08-22T14:47:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 20 Aug 2019, René Scharfe wrote:\n\n> Define enum parse_opt_result before using it in a typedef.  This avoids\n> the following compiler warning:\n>\n>    ./parse-options.h:53:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]\n>    typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n>                 ^\n>\n> While GCC and Clang both accept such a forward reference by default,\n> other compilers might be less forgiving.\n\nLooks obviously correct to me.\n\nThanks,\nDscho\n\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>  parse-options.h | 18 +++++++++---------\n>  1 file changed, 9 insertions(+), 9 deletions(-)\n>\n> diff --git a/parse-options.h b/parse-options.h\n> index a4bd40bb6a..38a33a087e 100644\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -46,6 +46,15 @@ enum parse_opt_option_flags {\n>  \tPARSE_OPT_COMP_ARG = 1024\n>  };\n>\n> +enum parse_opt_result {\n> +\tPARSE_OPT_COMPLETE = -3,\n> +\tPARSE_OPT_HELP = -2,\n> +\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n> +\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n> +\tPARSE_OPT_NON_OPTION,\n> +\tPARSE_OPT_UNKNOWN\n> +};\n> +\n>  struct option;\n>  typedef int parse_opt_cb(const struct option *, const char *arg, int unset);\n>\n> @@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);\n>\n>  /*----- incremental advanced APIs -----*/\n>\n> -enum parse_opt_result {\n> -\tPARSE_OPT_COMPLETE = -3,\n> -\tPARSE_OPT_HELP = -2,\n> -\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n> -\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n> -\tPARSE_OPT_NON_OPTION,\n> -\tPARSE_OPT_UNKNOWN\n> -};\n> -\n>  /*\n>   * It's okay for the caller to consume argv/argc in the usual way.\n>   * Other fields of that structure are private to parse-options and should not\n> --\n> 2.23.0\n>\n"}]}