Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: struct tag (*[5])(float) |
| Date | 2015-04-01 20:13 -0700 |
| Organization | None to speak of |
| Message-ID | <87bnj7i5nn.fsf@kst-u.example.com> (permalink) |
| References | <mfhjtf$plc$1@dont-email.me> <551C65E3.8010903@verizon.net> <mfhpfk$g36$1@dont-email.me> |
Bartc <bc@freeuk.com> writes:
> On 01/04/2015 22:40, James Kuyper wrote:
>> On 04/01/2015 04:17 PM, James Harris wrote:
>>> The type
>>>
>>> struct tag (*[5])(float)
>>>
>>> appears in at least two draft C standards: for C89 and the n869 pdf. I
>>> find it hard to read because it has no identifier. I can see where an
>>> identifier can be placed but how is a programmer *supposed* to parse
>>> such a "type" when reading a standard? Is it as simple as knowing which
>>> symbols are prefixes and which would be suffixes?
>>
>> What you are talking about is described in 6.7.7p2:
[snip]
> But is a human reader supposed to do keep all this in mind? It should
> be instantly obvious!
>
> I know there is an informal algorithm that can be used (and that
> people used to keep posting whenever I complained about complex
> typespecs), but I could never get it and just resorted to Cdecl
> instead. However the online Cdecl I used is no longer available, and I
> have to use trial and error.
http://cdecl.org/ is up and running. You should also be able to
insstall cdecl on your own system. For most Linux systems, it should be
available as an installable package (`sudo apt-get install cdecl` or
equivalent). If you're using Windows, I don't know how to install it,
but it should be possible; I vaguely recall that it's open-source.
Unfortunately for our current purpose, cdecl interprets declarations,
not types:
$ cdecl
Type `help' or `?' for help
cdecl> explain struct tag (*[5])(float)
syntax error
cdecl> explain struct tag (*FOO[5])(float)
declare FOO as array 5 of pointer to function (float) returning struct
tag
cdecl>
So it can explain what the type is -- but only if you know where to
insert the identifier.
> I could try and tell you what the above means, but it will a
> guess. Although I know the name goes just before the "*", because I
> tested my guess with a compiler.
No, it goes after the identifier. (And I don't think I can explain how
I figured that out.)
I agree with you that C's declaration syntax is unnecessarily obscure,
and I occasionally resort to cdecl myself.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
struct tag (*[5])(float) "James Harris" <james.harris.1@gmail.com> - 2015-04-01 21:17 +0100
Re: struct tag (*[5])(float) James Kuyper <jameskuyper@verizon.net> - 2015-04-01 17:40 -0400
Re: struct tag (*[5])(float) Bartc <bc@freeuk.com> - 2015-04-01 22:55 +0100
Re: struct tag (*[5])(float) Barry Schwarz <schwarzb@dqel.com> - 2015-04-01 16:01 -0700
Re: struct tag (*[5])(float) James Kuyper <jameskuyper@verizon.net> - 2015-04-01 19:29 -0400
Re: struct tag (*[5])(float) Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-02 05:28 -0700
Re: struct tag (*[5])(float) Bartc <bc@freeuk.com> - 2015-04-02 00:37 +0100
Re: struct tag (*[5])(float) Keith Thompson <kst-u@mib.org> - 2015-04-01 20:13 -0700
Re: struct tag (*[5])(float) Bartc <bc@freeuk.com> - 2015-04-02 10:30 +0100
Re: struct tag (*[5])(float) Keith Thompson <kst-u@mib.org> - 2015-04-02 15:18 -0700
Re: struct tag (*[5])(float) John Bode <jfbode1029@gmail.com> - 2015-04-02 15:22 -0700
csiph-web