Liste des Groupes | Revenir à cl c |
On 24/05/2024 12:14, bart wrote:At the moment I would expect most people who run the Baby X resource compiler to have a desktop machine with several gigabytes of memory istalled and 64 bit pointers.On 24/05/2024 02:39, Tim Rentsch wrote:Targeting 64-bit machines does not imply support for 64-bit types using standard C89 integer types. You probably find that most, if not all, C89 compilers that target 64-bit processors but have 32-bit "long" will have extensions for a 64-bit type. (It won't be an "extended integer type", as defined by the C standards, but it will be good enough for the job.) But if you use such extensions then you are not using standard C89.Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:>
>On 24/05/2024 00:52, Tim Rentsch wrote:>
>Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:>
>On 23/05/2024 23:49, Tim Rentsch wrote:>
>Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:>
>What is a good hash function for pointers to use in portable>
ANSI C?
I have a preliminary question. Do you really mean ANSI C, or
is C99 acceptable?
C89 is better.
But the pass has been sold.
I'm not asking which you think is better. I'm asking about
what your requirements are.
C 89.
I don't want to pull in C99 types and so on just for a hash function.
In that case I think you are stuck with using a half-baked
solution. The standard integer types available in C89 just
aren't a good fit in a 64-bit world.
I assume the C89 implementation is one that can target current 64 bit machines.
>
So if we use uintptr_t the code might break.Then char, short, int, long long will almost certainly have widths of 8, 16, 32 and 64 bits respectively.C89 does not have "long long". And "long" is 32-bit on 64-bit windows. There is no way in C89 to pick an integer type that is at least or exactly 64 bits. There is also no way to refer an integer type that is big enough to support an integer conversion from a pointer. (In C99, in <stdint.h>, you have "uintptr_t" and "intptr_t" which can be used if and only if the platform supports an integer type big enough for the integer conversion of pointers.)
>
(I don't know if 'long long' was part of C89, but it sounds like Malcolm just doesn't want to be bothered with stdint.h, and any compiler used is like to support it.
>
Les messages affichés proviennent d'usenet.