|
From: | Ken Raeburn |
Subject: | Re: Passing C pointers through guile |
Date: | Thu, 10 Jul 2008 11:11:14 -0400 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |