--- On Sat, 8/8/09, Alexei Sheplyakov <varg@metalica.kh.ua> wrote:
From: Alexei Sheplyakov <varg@metalica.kh.ua> Subject: Re: [GiNaC-devel] Fix the compliation error *for real* To: "GiNaC development list" <ginac-devel@ginac.de> Date: Saturday, August 8, 2009, 1:45 AM Hello,
On Fri, Aug 07, 2009 at 04:04:46PM -0700, Sergei Steshenko wrote:
Guys, I think a much more conceptually correct solution (even though this one works) would be to use
size_t
instead of
unsigned long .
The politically correct type is uintptr_t. And (AFAIK) the sizeof(size_t) is NOT guaranteed to be the same as sizeof(void*). And on any sane platform sizeof(long) == sizeof(void*) anyway.
Best regards, Alexei _______________________________________________
Alexei, this is what http://www.cplusplus.com/reference/clibrary/cstddef/size_t/ says: " size_t corresponds to the integral data type returned by the language operator sizeof and is defined in the <cstddef> header file (among others) as an unsigned integral type. It expresses a size or count in bytes. ". Please note that 'sizeof' argument is _not_ mentioned, and it makes sense. My logic us that since size_t is is good for _any_ object, it is good for any array A, including the array occupying the whole address space. Here is the same interpretation: http://www.viva64.com/terminology/size_t.html : " size_t. A basic unsigned integer C/C++ type. The type’s size is chosen in such a way as to allow you to write the maximum size of a theoretically possible array into it. On a 32-bit system size_t will take 32 bits and on a 64-bit one – 64 bits. In other words, a pointer can be safely put inside size_t type (an exception is class-function-pointers but this is a special case). size_t type is usually used for loop, array indexing, size storage and address arithmetic counters. In some cases using size_t type is more effective and safe than using a more habitual for the programmer unsigned type. " - please not the " In other words, a pointer can be safely put inside size_t type (an exception is class-function-pointers but this is a special case). size_t type is usually used for loop, array indexing, size storage and address arithmetic counters. " part. Regards, Sergei.