s*****w 发帖数: 1527 | 1 basically want to have a type like this,
for 32 bit windows, it's 32-bit int,
for 64-bit windows, it's 64-bit long long.
so i can use size_t for both user mode and kernel, for both 32-bit and 64-
bit windows ?
note unix is much better, int is portable. | n**f 发帖数: 121 | 2 Gut feeling is that size_t is at most as portable as int. If you have issues
porting int, size_t will probably fail.
Just curious why you are concerned with portability of size_t? 32 vs. 64 bit
should only matters if you are dealing with things like numerical
computation (and thus the numbers are so large).
【在 s*****w 的大作中提到】 : basically want to have a type like this, : for 32 bit windows, it's 32-bit int, : for 64-bit windows, it's 64-bit long long. : so i can use size_t for both user mode and kernel, for both 32-bit and 64- : bit windows ? : note unix is much better, int is portable.
| s*****w 发帖数: 1527 | 3 if you want to get the different for 2 pointers,
they are either 32-bit pointers or 64-bit, the result comes back as an int
or int64, that's why i was thinking about size_t
issues
bit
【在 n**f 的大作中提到】 : Gut feeling is that size_t is at most as portable as int. If you have issues : porting int, size_t will probably fail. : Just curious why you are concerned with portability of size_t? 32 vs. 64 bit : should only matters if you are dealing with things like numerical : computation (and thus the numbers are so large).
| s*****w 发帖数: 1527 | 4 ok, in my 64-bit pc,
size_t = unsigned log long
in 32-bit, it's unsigned int which is int32
issues
bit
【在 n**f 的大作中提到】 : Gut feeling is that size_t is at most as portable as int. If you have issues : porting int, size_t will probably fail. : Just curious why you are concerned with portability of size_t? 32 vs. 64 bit : should only matters if you are dealing with things like numerical : computation (and thus the numbers are so large).
| n**f 发帖数: 121 | 5 Are you trying to infer the distance between two array elements?
【在 s*****w 的大作中提到】 : if you want to get the different for 2 pointers, : they are either 32-bit pointers or 64-bit, the result comes back as an int : or int64, that's why i was thinking about size_t : : issues : bit
| s*****w 发帖数: 1527 | 6 a simpled version
pdest = _tcsstr(string, _T("pattern") ); // which is a strstr in ascii
result = pdest - string + 1;
printf ("pattern is found at position %d of the string");
【在 n**f 的大作中提到】 : Are you trying to infer the distance between two array elements?
| n**f 发帖数: 121 | 7 My 2 cents is that: if an int fails in any edge case, a size_t will probably
fail too.
Also see the example in MSDN
http://msdn.microsoft.com/en-us/library/z9da80kz(v=vs.80).aspx
They use int.
【在 s*****w 的大作中提到】 : a simpled version : pdest = _tcsstr(string, _T("pattern") ); // which is a strstr in ascii : result = pdest - string + 1; : printf ("pattern is found at position %d of the string");
| t****t 发帖数: 6806 | 8 the type of the difference of two pointers is ptrdiff_t, not size_t. size_t
is unsigned, while ptrdiff_t is signed.
【在 s*****w 的大作中提到】 : if you want to get the different for 2 pointers, : they are either 32-bit pointers or 64-bit, the result comes back as an int : or int64, that's why i was thinking about size_t : : issues : bit
|
|