git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] parseopt: move definition of enum parse_opt_result up

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 22, 2019, 14:47 UTC
Message-ID
<nycvar.QRO.7.76.6.1908221646460.46@tvgsbejvaqbjf.bet>
In-Reply-To
<58e5dd7b-d577-a1d9-c704-44642f553323@web.de>
Hi,
On Tue, 20 Aug 2019, René Scharfe wrote:
Show 9 quoted lines
> 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.
Looks obviously correct to me.

Thanks, Dscho

Show 45 quoted lines
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  parse-options.h | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/parse-options.h b/parse-options.h
> index a4bd40bb6a..38a33a087e 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -46,6 +46,15 @@ enum parse_opt_option_flags {
>  	PARSE_OPT_COMP_ARG = 1024
>  };
>
> +enum parse_opt_result {
> +	PARSE_OPT_COMPLETE = -3,
> +	PARSE_OPT_HELP = -2,
> +	PARSE_OPT_ERROR = -1,	/* must be the same as error() */
> +	PARSE_OPT_DONE = 0,	/* fixed so that "return 0" works */
> +	PARSE_OPT_NON_OPTION,
> +	PARSE_OPT_UNKNOWN
> +};
> +
>  struct option;
>  typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
>
> @@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);
>
>  /*----- incremental advanced APIs -----*/
>
> -enum parse_opt_result {
> -	PARSE_OPT_COMPLETE = -3,
> -	PARSE_OPT_HELP = -2,
> -	PARSE_OPT_ERROR = -1,	/* must be the same as error() */
> -	PARSE_OPT_DONE = 0,	/* fixed so that "return 0" works */
> -	PARSE_OPT_NON_OPTION,
> -	PARSE_OPT_UNKNOWN
> -};
> -
>  /*
>   * It's okay for the caller to consume argv/argc in the usual way.
>   * Other fields of that structure are private to parse-options and should not
> --
> 2.23.0
>
Previous: René Scharfe
Message 2 of 2 in “parseopt: move definition of enum parse_opt_result up”
  1. parseopt: move definition of enum parse_opt_result upRené Scharfe, Aug 20, 2019
  2. Johannes SchindelinAug 22, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.