1

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

2
  • That’s just the API. You would choose a different hash table if that is truly a requirement.
    – TingPing
    Commented Dec 1 at 2:45
  • What hash table would you recommend? I need fast implementation with 64/128-bit hashing support and wide amount of tools for operating them (like g_hash_table function set) Commented Dec 1 at 6:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.