|
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) |
Date: | Wed, 26 Aug 2009 20:03:35 +0100 |
User-agent: | Mutt/1.5.13 (2006-08-11) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |