#ifndef UNSAFE_H #define UNSAFE_H #define reinterpret_cast(T, it) _unsafe_cast_##T(0, it) #define X(T) T _unsafe_cast_##T(int dummy, ...) { return ...(0, T); } X(bool) X(int) X(float) X(entity) X(string) typedef float(...) rawfunc; X(rawfunc) #undef X #define strid(s) ITOF(reinterpret_cast(int, s)) .int _unsafe_fld1, _unsafe_fld2; int INTEGER_ONE; #define FTOI(f) ((f) * INTEGER_ONE) #define ITOF(i) ((i) / INTEGER_ONE) STATIC_INIT(INTEGER_ONE) { INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1); } #endif