Closed xan1242 closed 2 years ago
For SOME reason this works standalone:
#include <iostream>
template <int V> static constexpr int compiler_stringhash_template = V;
static constexpr int compiler_stringhash(const char* str)
{
if (str == NULL)
return 0;
char* _str = ((char*)str);
int result = -1;
while (*_str != 0)
{
result = result * 0x21 + (unsigned int)(*_str);
_str = _str + 1;
}
return result;
}
#define NFS_HASH(s) compiler_stringhash_template<compiler_stringhash(s)>
int main()
{
std::cout << NFS_HASH("test");
}
I don't understand what's going on anymore...
Using NFS_HASH("test");
works, but using NFS_HASH("XINPUT_GAMEPAD_DPAD_UP");
doesn't...
The plot thickens...
This seems to have broken with MSVC 19.32
clang provided an ACTUAL explanation of what happened...
<source>:12:19: note: value 2241911859 is outside the range of representable values of type 'int'
result = result * 0x21 + (unsigned int)(*_str);
THANK YOU CLANG FOR BEING USEFUL... and useless at the same time, but eh, what can we do about growing pains of compilers...
This started happening after I've updated my Visual Studio to the latest available version.
Specifically, it's complaining about this: https://github.com/xan1242/NFS-XtendedInput/blob/7bb5ec575ccdbdf410dc8dd7c9682c59eb5dc466/NFS_XtendedInput.h#L3
https://github.com/xan1242/NFS-XtendedInput/blob/7bb5ec575ccdbdf410dc8dd7c9682c59eb5dc466/NFS_XtendedInput.h#L21
It seems like a recurring issue: Link
I'll need some magicians to figure this one out...
For reference: I have Visual Studio 2022 17.3.3
I've also tested this on my laptop which has VS2022 17.0.5 and it works over there.