C struct construct question

Behdad Esfahbod behdad-26n5VD7DAF2Tm46uYYfjYg at public.gmane.org
Tue Apr 18 15:55:06 UTC 2006


On Tue, 18 Apr 2006, John Vetterli wrote:

> On Tue, 18 Apr 2006, Peter wrote:
> > I found an unusual C construct in Asterisk source code and I am looking for
> > an explanation. Of course I cannot find one online. Here is a quote:
> > static const struct ast_channel_tech local_tech = {
> >        .type = type,
> >        .description = tdesc,
> >        .capabilities = -1,
> >        .requester = local_request,
> >        .send_digit = local_digit,
> > 	.call = local_call,
> >        .hangup = local_hangup,
> >        .answer = local_answer,
> >        .read = local_read,
> >        .write = local_write,
> >        .exception = local_read,
> >        .indicate = local_indicate,
> >        .fixup = local_fixup,
> >        .send_html = local_sendhtml, };
> > how does this work ? References ?
>
> This syntax specifies which field in struct ast_channel_tech receives
> which value, as opposed to having to list the the values in the same order
> as they were declared in. Have a look at:
>
>    http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Designated-Inits.html
>
> That web page is for gcc version 4.1.0, but that feature seems to have
> been in gcc since the first 3.x release.

Yes, and this is a C99 addition.


> HTH
> JV

--behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
	-- Dan Bern, "New American Language"
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list