From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.lisp.guile.user Subject: Re: Passing C pointers through guile Date: Thu, 10 Jul 2008 11:11:14 -0400 Message-ID: <85E93FB6-A50A-4A6A-8DAB-7ACEE47B3928@raeburn.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216796192 28671 80.91.229.12 (23 Jul 2008 06:56:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 23 Jul 2008 06:56:32 +0000 (UTC) Cc: guile-user@gnu.org, Greg Troxel To: "Kjetil S. Matheussen" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jul 23 08:57:20 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KLYHi-00008t-1b for guile-user@m.gmane.org; Wed, 23 Jul 2008 08:57:14 +0200 Original-Received: from localhost ([127.0.0.1]:40405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLYGo-0007m7-Lp for guile-user@m.gmane.org; Wed, 23 Jul 2008 02:56:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLYGk-0007m2-BA for guile-user@gnu.org; Wed, 23 Jul 2008 02:56:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLYGh-0007ln-WE for guile-user@gnu.org; Wed, 23 Jul 2008 02:56:13 -0400 Original-Received: from [199.232.76.173] (port=38353 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLYGh-0007lk-PG for guile-user@gnu.org; Wed, 23 Jul 2008 02:56:11 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:6060) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KLYGh-0007pL-52 for guile-user@gnu.org; Wed, 23 Jul 2008 02:56:11 -0400 Original-Received: from c-65-96-169-35.hsd1.ma.comcast.net ([65.96.169.35] helo=raeburn.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KLYGg-00060G-6i for guile-user@gnu.org; Wed, 23 Jul 2008 02:56:10 -0400 Original-Received: from squish.raeburn.org (squish.raeburn.org [69.25.196.102]) by raeburn.org (8.14.1/8.12.11) with ESMTP id m6AFBEKJ028225; Thu, 10 Jul 2008 11:11:15 -0400 (EDT) In-Reply-To: X-Mailer: Apple Mail (2.926) X-detected-kernel: by mx20.gnu.org: NetBSD 3.0 (DF) X-Greylist: delayed 2515 seconds by postgrey-1.27 at nadesico; Wed, 23 Jul 2008 02:55:49 EDT X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6691 Archived-At: On Jul 9, 2008, at 12:55, Kjetil S. Matheussen wrote: > On Wed, 9 Jul 2008, Greg Troxel wrote: >> Does C guarantee that pointers fit in unsigned long? > I don't know. But in practice: Yes. According to various sources, 64-bit Windows uses an LLP64 model -- meaning long is 32 bits, long long and pointers are 64 bits. So, no. Near as I can tell, C99 does not require that there be *any* integral type large enough to hold a pointer value (6.3.2.3 paragraph 6); and specifically, uintptr_t and intptr_t are optional types. However, I expect any C99 implementation we're likely to run across will have such a type, and will define [u]intptr_t. I don't have a copy of the C89 spec handy, though, and unfortunately that's where most compilers are these days. In practice, it's also probably safe to use unsigned long long (or whatever Windows calls it) on the platforms that have it, and unsigned long on those that don't. But testing compiler properties in autoconf and then using them in your installed headers may tie you to a particular compiler when more than one may be available (e.g., vendor's compiler and gcc). Ken