Lee Shadmi
Lee Shadmi

Reputation: 17

Converting differences between VS 2010 and 2015

Hi I have this code that was written in VS2010:

unsigned long CHwFingerprint::toHash(wstring& wmisignature)
{
    if (wmisignature.empty())
        wmisignature = _empty;

    hash<wstring> str_hash;
    unsigned long hash = (unsigned long)str_hash(wmisignature);
    return hash;
}

*wstring is just a Unicode string that we created and can be used as CString...

Now I get different results when I use this code in VS 2015. For example if wmisignature=HMT351U6CFR8C-PB Then the results will be as follow:

Any ideas why?

Upvotes: 1

Views: 70

Answers (2)

Moti Hamo
Moti Hamo

Reputation: 198

Right click the project and select properties. Under configuration->General->Platform Tool Set, change to v100.

Upvotes: 0

Jarod42
Jarod42

Reputation: 217398

The actual hash functions are implementation-dependent, so may differ from compilers...

and since C++14:

Hash functions are only required to produce the same result for the same input within a single execution of a program; this allows salted hashes that prevent collision denial-of-service attacks.

Upvotes: 5

Related Questions