public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Andy <borucki.andrzej@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How to explain this syntax?
Date: Wed, 19 Apr 2023 19:53:49 +0800	[thread overview]
Message-ID: <4b7bcfa747873836baa77c042087545330396996.camel@xry111.site> (raw)
In-Reply-To: <CAE2KeA+dFo_+SUSVzB4MxX3tdOw04Kns5tum0wB613Na5Jvq7A@mail.gmail.com>

On Wed, 2023-04-19 at 13:40 +0200, Andy via Gcc-help wrote:
> I meet odd struct + colon syntax:
> in gcc/gcc/testsuite/gcc.c-torture/compile/init-3.c
> is
> 
> struct something X = {
>  foo: { },
>  bar: 1,
> };
> bar:1 is one bit field? what means foo? is the same as
> struct empty foo; where struct empty { };
> colon is not only reserved to bitfields?

It's an obsoleted GNU extension:

https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

> 
> Second (init-2.c):
> initializer
> 
> struct
> {
>   int e1, e2;
> } v = { e2: 0 };
> why not e2=0, colon instead of assign operator?

The point of the test case is ensuring GCC backward compatible with the
old extension, though it's obsoleted.

The GCC test cases are test cases, not some "material to learn C".

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-04-19 11:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 10:25 Andy
2023-04-16 10:53 ` Andrew Haley
2023-04-19 11:40 ` Andy
2023-04-19 11:53   ` Xi Ruoyao [this message]
2023-04-19 12:35     ` Andy
2023-04-19 12:41       ` Xi Ruoyao

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b7bcfa747873836baa77c042087545330396996.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=borucki.andrzej@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /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.
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).