#define HASH_BASE 2166136261 #define HASH_MULT 16777619 #define HASH_ROUND(prev_hash, next_char) \ unsigned((prev_hash ^ next_char) * (next_char ? HASH_MULT : 1)) #define HASH_IMPL(f, s) f(f(f(f( f(f(f(f( HASH_BASE \ , s[0]), s[1]), s[2]), s[3]), s[4]), s[5]), s[6]), s[7]) #define HASH(str) HASH_IMPL(HASH_ROUND, (str "\0\0\0\0" "\0\0\0\0")) // FNV-1a hash unsigned hash(const char* s) { unsigned value = HASH_BASE; for(; *s; ++s) value = (value ^ *s) * HASH_MULT; return value; }
Monday, November 29, 2010
C++: How to calculate string hash at compile-time
Sunday, November 21, 2010
Windows error reporting in C++
This post describes how to convert GetLastError() result to text message.
Tuesday, November 9, 2010
Building Python in MSVC2010 with static runtime.
This guide will show an incomplete way how to build CPython (3.1.2, but I think it will work for another versions too) in MSVC2010 with static runtime (/MT option).
Subscribe to:
Posts (Atom)