From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Michael Haggerty <mhagger@alum.mit.edu>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Forward declaration of enum iterator_selection?
Date: Mon, 8 Aug 2016 19:52:05 +0100 [thread overview]
Message-ID: <53ab8626-f862-a732-b369-abeab69a468f@ramsayjones.plus.com> (raw)
In-Reply-To: <c1ef8a65-844f-b676-cae0-abba87930063@ramsayjones.plus.com>
On 08/08/16 19:28, Ramsay Jones wrote:
>
>
> On 08/08/16 17:30, Johannes Sixt wrote:
>> Am 07.08.2016 um 22:34 schrieb Ramsay Jones:
>>> On 05/08/16 23:26, Johannes Sixt wrote:
> [snip]
>>> At this point 'enum iterator_selection' is an incomplete type and may
>>> be used when the size of the object is not required. It is not needed,
>>> for example, when a typedef name is being declared as a pointer to, or
>>> as a function returning such a type. However, such a type must be
>>> complete before such a function is called or defined.
>>
>> All you say is true when it is a struct type, of course. But I doubt that there exists such a thing called "incomplete enumeration type" in C. In fact, with these keywords I found https://gcc.gnu.org/onlinedocs/gcc/Incomplete-Enums.html which indicates that this is a GCC extension.
>
> Ah, well spotted!
>
> You prompted me to look at the C99 (and C11) standards, in particular
> sections 6.7.2.2 (Enumeration specifiers) and 6.7.2.3 (Tags).
>
> So, while (technically) enumeration types are incomplete prior to the
> closing } in its definition, the constraint imposed in 6.7.2.3-2 states:
>
> "A type specifier of the form
> enum identifier
> without an enumerator list shall only appear after
> the type it specifies is complete"
>
> which pretty much rules out its use here.
BTW, you can make gcc be that 'pickier compiler' you mentioned, thus:
$ rm refs.o
$ make CFLAGS='-g -O2 -Wall -std=c99 -pedantic' refs.o
* new build flags
CC refs.o
In file included from refs.c:8:0:
refs/refs-internal.h:363:14: warning: ISO C forbids forward references to ‘enum’ types [-Wpedantic]
typedef enum iterator_selection ref_iterator_select_fn(
^
$
:-D
ATB,
Ramsay Jones
next prev parent reply other threads:[~2016-08-08 18:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-05 22:26 Forward declaration of enum iterator_selection? Johannes Sixt
2016-08-07 20:34 ` Ramsay Jones
2016-08-08 16:30 ` Johannes Sixt
2016-08-08 18:28 ` Ramsay Jones
2016-08-08 18:52 ` Ramsay Jones [this message]
2016-08-10 22:46 ` Michael Haggerty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53ab8626-f862-a732-b369-abeab69a468f@ramsayjones.plus.com \
--to=ramsay@ramsayjones.plus.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=mhagger@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).