From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 9C42F3858002 for ; Wed, 19 Apr 2023 11:53:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C42F3858002 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1681905237; bh=UOpbiss1gGbPwHEw0s2URKZZmEuxzWTX9Ecd9zwQ1mw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AbDH97jYwwm4Yx9peD52L9oLmYgyx3TdL0CDxG9a1eZNKE8EbChWRLEwIjdJ0lkRV Mfv0sfUp7kvEvf8D+ESK24OAwz5H3KdRdlUDXfbR73Fwl6n3vg7gGFJ6Gp2uOUMcwJ f5BCw3val2WmAVdiBb/H5VzmF5tY8Q/EBFIKPe+w= Received: from [192.168.124.11] (unknown [113.140.11.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id BD20665C4C; Wed, 19 Apr 2023 07:53:56 -0400 (EDT) Message-ID: <4b7bcfa747873836baa77c042087545330396996.camel@xry111.site> Subject: Re: How to explain this syntax? From: Xi Ruoyao To: Andy Cc: gcc-help@gcc.gnu.org Date: Wed, 19 Apr 2023 19:53:49 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,LIKELY_SPAM_FROM,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 >=20 > struct something X =3D { > =C2=A0foo: { }, > =C2=A0bar: 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 >=20 > Second (init-2.c): > initializer >=20 > struct > { > =C2=A0 int e1, e2; > } v =3D { e2: 0 }; > why not e2=3D0, 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". --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University