From owner-freebsd-current@FreeBSD.ORG Fri Jul 11 03:07:27 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 87EDD37B401 for ; Fri, 11 Jul 2003 03:07:27 -0700 (PDT) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 036AD43FBD for ; Fri, 11 Jul 2003 03:07:27 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from dialup-67.30.108.143.dial1.sanjose1.level3.net ([67.30.108.143] helo=mindspring.com) by stork.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19auoF-0001GV-00; Fri, 11 Jul 2003 03:07:23 -0700 Message-ID: <3F0E8B54.94DAF984@mindspring.com> Date: Fri, 11 Jul 2003 03:03:00 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: David Leimbach References: <6006001.1057858723473.JavaMail.leimy2k@mac.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a4a7e0faac85f02985bda81ddebe45250f350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c cc: Luigi Rizzo cc: current@freebsd.org Subject: Re: what is the suggested way to do void * arithmetic ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jul 2003 10:07:27 -0000 David Leimbach wrote: > I always feel better when I convert void * to char * but that's probably > because C++ doesn't allow pointer arithmetic on void *'s. The argument > being that you don't know the size of what's being pointed to with a void * > and therefore can't know how far to seek the the pointer to get to the next > valid address. C++ is pretty freaking draconian in this regard. You basically have to use a dynamic cast, where you would use a cast to void * and another to some other type * in order to coerce the value. The main issue is that there are pointer types, and then there are object types, and coercion between the two is strongly discouraged in order to get you to use proper inheritance (that's what Bjarne said, anyway). I don't know if you can do "normal" coercion with the really "standard" flags on in the 3.3 compiler; I guess we'll get to find out soon enough... -- Terry