From: Greg C. <chi...@co...> - 2006-09-26 12:40:36
|
On 2006-9-26 7:36 UTC, Kai Tietz wrote: > > [...] the major problem is the ISO definition of the pointer > difference, which lead to a long type. What implicit means, that a long > needs to have the same size as a pointer itself. Even MS reflect this by > defining intptr_t to an __int64 type. The C standard, ISO/IEC 9899, says at 6.5.6/9 When two pointers are subtracted, [...] the size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t 6.2.5/4 defines signed integer types to include implementation- defined extended types. Thus, ptrdiff_t does not need to be the same as long int. > If we change the ISO-C type "long", it means that programmer needs to > learn that pointer differences are "__int64" not "long", which for my > opinion looks more worse. Programmers should use ptrdiff_t directly, and not assume that it's the same as any particular type. |