From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgNmp-0003J4-8p for qemu-devel@nongnu.org; Wed, 26 Aug 2009 15:03:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgNmk-00039I-Du for qemu-devel@nongnu.org; Wed, 26 Aug 2009 15:03:58 -0400 Received: from [199.232.76.173] (port=58891 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgNmj-00038l-N3 for qemu-devel@nongnu.org; Wed, 26 Aug 2009 15:03:53 -0400 Received: from mail2.shareable.org ([80.68.89.115]:57551) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MgNmi-0003o6-Gu for qemu-devel@nongnu.org; Wed, 26 Aug 2009 15:03:52 -0400 Date: Wed, 26 Aug 2009 20:03:35 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] Coding style, C++ compatible code (was Re: [Qemu-devel] [PATCH 02/22] eepro100: cast a void * makes no sense) Message-ID: <20090826190335.GG25726@shareable.org> References: <51486eb6860d1680c1bce45e310dcd3aae096f43.1251111439.git.quintela@redhat.com> <4A928DF0.9000106@weilnetz.de> <87tyzxnwvb.fsf@pike.pond.sub.org> <4A953E20.8080806@mail.berlios.de> <4A954B61.4010708@redhat.com> <20090826170402.GA25726@shareable.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc Cc: qemu-devel@nongnu.org, Anthony Liguori , Gerd Hoffmann , Markus Armbruster malc wrote: > > > (1) structs pointing to each other, like this: > > > > > > typedef struct A A; > > > typedef struct B B; > > > > You can use "typedef struct _A A" to be C++ compatible, but it fails > > to be shorter so I wouldn't recommend it ;-) > > This is neither C nor C++ compatible, in fact it breaks both. You'll have to explain that statement. It compiles fine for me in C and C++: typedef struct _A A; typedef struct _B B; struct _A { struct _B *b; }; struct _B { struct _A *a; }; A *foo(B *arg); Using this works equally well: struct _A { B *b; }; struct _B { A *a; }; -- Jamie