This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libstdc++] intptr_t usage
- From: Richard Henderson <rth at redhat dot com>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Mar 2007 16:29:10 -0700
- Subject: Re: [libstdc++] intptr_t usage
- References: <20070327220453.GA4342@redhat.com> <46099F40.4060409@suse.de>
On Wed, Mar 28, 2007 at 12:48:32AM +0200, Paolo Carlini wrote:
> >I'm not sure what's required generically to assert that intptr_t is
> >present; certainly it's available on Linux and Win64...
> >
> Yes, that's a problem, it's available only in C99, and we can't assume
> that kind of libc, in general. I don't know, maybe we can use long long
> (or maybe better, unsigned long long), and choose the right type via
> something like:
>
> typedef __gnu_cxx::__conditional_type<(sizeof(const void*) <=
> sizeof(unsigned long)), unsigned long, unsigned long long>::__type
> _UIntPtrType;
>
> Is it sufficient to cover all the targets where libstdc++ actually
> works?
Dunno. Another alternative would be
#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
typedef unsigned long _UIntPtrType;
#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
typedef unsigned long long _UIntPtrType;
#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
typedef unsigned int _UIntPtrType;
#elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
typedef unsigned short int _UIntPtrType;
#else
#error
#endif
r~