How can I make GHashTable work with 64-bit hash?

I approached a problem when I tried to use XXH3_64bit from <xxhash.h> module over the wrapper with __fastcall for GHashTable initialization, but the type definition for GHashFunc requires the function to return a 32-bit hash instead, however there is no 32-bit implementation for XXH3 hash function. I specifically intend to use XXH3 variant and not older and slower XXH, like XXH32. How can I resolve this issue?

Simplified code:

#define XXH_INLINE_ALL
#define XXH_NAMESPACE
#include <xxhash.h>
#include <stdlib.h>
#include <glib.h>

uint_fast64_t __fastcall xxh3_64bits_map(const void* key) {
    return XXH3_64bits(key, _countof(key));
}

int main(int argc, char* argv[]) {
    /* No need to compare any values, hence GEqualFunc is NULL */
    GHashTable* hash_table = g_hash_table_new(xxh3_64bits_map, NULL);

    return 0;
}

Error in the terminal:

error: passing argument 1 of 'g_hash_table_new' from incompatible pointer type [-Wincompatible-pointer-types]
  12 |     GHashTable* hash_table = g_hash_table_new(xxh3_64bits_map, NULL);

No solutions available searching with GHashFunc 64 [c] in a search bar

gcc --version: gcc.exe (Rev1, Built by MSYS2 project) 14.2.0

Upvotes: 1

Views: 48

Answers (0)

Related Questions