From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 16 14:18:28 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A45B09D0 for ; Thu, 16 Jan 2014 14:18:28 +0000 (UTC) Received: from mta04.bitpro.no (mta04.bitpro.no [92.42.64.203]) by mx1.freebsd.org (Postfix) with ESMTP id 5F788110E for ; Thu, 16 Jan 2014 14:18:28 +0000 (UTC) Received: from mail.lockless.no (mail.lockless.no [46.29.221.38]) by mta04.bitpro.no (Postfix) with ESMTPS id 87E111002B7; Thu, 16 Jan 2014 15:01:23 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.lockless.no (Postfix) with ESMTP id E14648EFB4A; Thu, 16 Jan 2014 15:02:11 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at lockless.no Received: from mail.lockless.no ([127.0.0.1]) by localhost (mail.lockless.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a3l+MwkTupJ1; Thu, 16 Jan 2014 15:02:11 +0100 (CET) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) by mail.lockless.no (Postfix) with ESMTPSA id 04B898EFB44; Thu, 16 Jan 2014 15:02:10 +0100 (CET) Message-ID: <52D7E674.4010501@bitfrost.no> Date: Thu, 16 Jan 2014 15:02:28 +0100 From: Hans Petter Selasky Organization: Bitfrost A/S User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Poul-Henning Kamp Subject: Re: Make "sys/queue.h" usable with C++ References: <52D7D302.3090403@bitfrost.no> <1679.1389879981@critter.freebsd.dk> In-Reply-To: <1679.1389879981@critter.freebsd.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jan 2014 14:18:28 -0000 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