in reply to Re^5: [OT] LLP64 .v. LP64 portability
in thread [OT] LLP64 .v. LP64 portability
I'm not familiar with those types.
They are standard types for microsoft compilers: MS CRT Standard types.
STRLEN should remain whatever strlen returns. That is usually size_t, and it's accessed via Size_t.
The problem is, as you pointed out above, size_t, (actually defined as what sizeof() returns), is an unsigned type, and therefore cannot handle negative indexing.
And since (on 32-bit), it isn't possible to have strings longer than 2GB, to me it makes sense to avoid the need for casting between signed and unsigned, and all the noise that adds to the sources, by utilising the otherwise unused high-bit to accommodate both Perl's negative indexing, and general pointer math.
ptrdiff_t (long integer or __int64, depending on the target platform) Result of subtraction of two pointers.
Seems to be perfectly defined for this purpose.
POSIX (though not ANSI or ISO) also define an equivalent type ssize_t for similar reasons.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: [OT] LLP64 .v. LP64 portability
by ikegami (Patriarch) on Apr 22, 2010 at 05:47 UTC | |
by BrowserUk (Patriarch) on Apr 22, 2010 at 05:57 UTC | |
by ikegami (Patriarch) on Apr 22, 2010 at 06:29 UTC | |
by BrowserUk (Patriarch) on Apr 23, 2010 at 05:51 UTC | |
by ikegami (Patriarch) on Apr 23, 2010 at 06:04 UTC | |
by ikegami (Patriarch) on Apr 23, 2010 at 06:07 UTC | |
by ikegami (Patriarch) on Apr 23, 2010 at 06:06 UTC |