ZTzTopia / GTProxy

⚖️ A proxy for growtopia. NO SHADOW BAN!
MIT License
57 stars 38 forks source link

Compilation errors #28

Closed Gold512 closed 1 year ago

Gold512 commented 1 year ago

Unable to get the executable when i run cmake --build . Errors:

gtproxy\src\client\../utils/hash.h(6): error C3615: constexpr function 'utils::fnv1a_hash' cannot result in a constant expression
GTProxy\src\client\client.cpp(113): error C2051: case expression not constant error C2051: case expression not constant
GTProxy\src\client\client.cpp(127): error C2051: case expression not constant
gtproxy\src\utils\hash.h(6): error C3615: constexpr function 'utils:: fnv1a_hash' cannot result in a constant expression
gtproxy\src\utils\hash.h(6): error C3615: constexpr function 'utils:: 
fnv1a_hash' cannot result in a constant expression 
Gold512 commented 1 year ago

modifying fnv1a_hash to

constexpr std::size_t fnv1a_hash(const std::string_view& data)
{
    // Fowler/Noll/Vo 1a variant.

    // 32-bit
    std::size_t prime = 16777619U;
    std::size_t offset_basis = 2166136261U;

    if constexpr (sizeof(std::size_t) == 8) {
        // 64-bit
        prime = 1099511628211ULL;
        offset_basis = 14695981039346656037ULL;
    }

    std::size_t hash{ offset_basis };
    for (auto& c : data) {
        hash ^= c;
        hash *= prime;
    }

    return hash;
}

seems to have fixed it so i'll mark it as closed

ZTzTopia commented 1 year ago

oh what's the different?