Date: Thu, 16 Jan 2014 15:02:28 +0100 From: Hans Petter Selasky <hps@bitfrost.no> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: Make "sys/queue.h" usable with C++ Message-ID: <52D7E674.4010501@bitfrost.no> In-Reply-To: <1679.1389879981@critter.freebsd.dk> References: <52D7D302.3090403@bitfrost.no> <1679.1389879981@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Paul-Henning, On 01/16/14 14:46, Poul-Henning Kamp wrote: > In message <52D7D302.3090403@bitfrost.no>, Hans Petter Selasky writes: >> Hi, >> >> I'm using "sys/queue.h" with some C++ programs. The only problem is that >> you cannot make an ENTRY() using classes without getting some compiler >> warnings, because all macros in "sys/queue.h" assume "struct". > > I came >< this close to removing the assumed struct many years ago > when I orthogonalized sys/queue.h, but were persuaded by others that > it was pointless and that nobody were ever going to use it with C++ > anyway, C++ being so much more evolved in such aspects :-) > Pointless ... hmm. After I've been programming some years in the kernel, I see no better way to make linked lists than using the macros inside "sys/queue.h". I love em. They are simple and straight forward. And gives you the flexibility of choosing the list type. Even GDB can be made to understand them. In my current code I simply: #define struct TAILQ_XXX() #undef struct And that works the few places I need it. > Wouldn't > > #ifndef SYS_QUEUE_STRUCT > # define SYS_QUEUE_STRUCT struct > #endif > > Make more sense ? That's a valid possibility too. I would suggest stripping the SYS_ prefix because the queue file can reside other places too. Or make one macro for each list type? #ifndef TAILQ_STRUCT #define TAILQ_STRUCT struct #endif #ifndef LIST_STRUCT #define LIST_STRUCT struct #endif and so on? > > That would allow C code to also make the struct explicit. > Or for allowing typedef'ed structures. Will you make a patch for it? Another question: Who will distribute the queue.h updates to Linux and other OS'es. I see the Linux's sys/queue.h is already a bit behind ours. --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52D7E674.4010501>