From owner-freebsd-questions@FreeBSD.ORG Tue Feb 1 19:40:00 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BEE9316A4CE for ; Tue, 1 Feb 2005 19:40:00 +0000 (GMT) Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net [69.17.117.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F0DA43D45 for ; Tue, 1 Feb 2005 19:40:00 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: (qmail 3733 invoked from network); 1 Feb 2005 19:39:59 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 1 Feb 2005 19:39:59 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id 08FBD84; Tue, 1 Feb 2005 14:39:59 -0500 (EST) Sender: lowell@be-well.ilk.org To: Charles Swiger References: <20050201164337.GA78979@dogma.freebsd-uk.eu.org> <62f97b906f93154c70f01d754d50083c@mac.com> From: Lowell Gilbert Date: 01 Feb 2005 14:39:58 -0500 In-Reply-To: <62f97b906f93154c70f01d754d50083c@mac.com> Message-ID: <443bwgm5m9.fsf@be-well.ilk.org> Lines: 22 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: Jonathon McKitrick cc: freebsd-questions@freebsd.org Subject: Re: Unix equivalent of a variant?? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Feb 2005 19:40:00 -0000 Charles Swiger writes: > On Feb 1, 2005, at 11:43 AM, Jonathon McKitrick wrote: > > I need the equivalent of a variant, however. A hold-everything > > variable > > that can be any type in C/C++. Is there something already out there > > I can > > use or should I just roll my own? > > Your question probably belongs on comp.lang.c, but the cannonical way > of handling "data of any type" is a memory buffer and a (void *). > Watch out for host data alignment restrictions. Or depending on the intent, a union, which will get the compiler to take care of alignment. Generally, though, avoiding typechecking is a hack best avoided... -- Lowell Gilbert, embedded/networking software engineer, Boston area http://be-well.ilk.org/~lowell/