Change constant declaration and macro usage so it no longer relies on undefined behaviour. Fix GCC compiler errors.