From 448f04aff1e2b96287f37755ef1b12d9339ea135 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 3 Jun 2007 14:19:43 +0000 Subject: Fixed warning about strict-aliasing rules and don't die on warnings by default. --- ChangeLog | 2 ++ src/Makefile.am | 2 +- src/utils/fastsqrt.h | 13 +++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5b5230b..7d32cc24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * src/CMakeLists.txt, src/Makefile.am, docs/Makefile.am: Added some files to be included with the release. + * src/utils/fastsqrt.h: Fixed warning about strict-aliasing rules. + * src/Makefile.am: Don't die on warnings by default. 2007-06-02 Bjørn Lindeijer diff --git a/src/Makefile.am b/src/Makefile.am index 9e6cb4c5..207689cb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -281,6 +281,6 @@ INCLUDES = \ # the library search path. tmw_LDFLAGS = $(all_libraries) $(LIBSDL_RPATH) `pkg-config --libs libxml-2.0` -tmw_CXXFLAGS = -Wall -Werror $(OPENGL_CFLAGS) $(LIBSDL_CFLAGS) `pkg-config --cflags libxml-2.0` $(CURL_CFLAGS) +tmw_CXXFLAGS = -Wall $(OPENGL_CFLAGS) $(LIBSDL_CFLAGS) `pkg-config --cflags libxml-2.0` $(CURL_CFLAGS) tmw_LDADD = $(LIBSDL_LIBS) -lguichan_sdl $(OPENGL_LIBS) $(CURL_LIBS) tmw_TARGET = tmw diff --git a/src/utils/fastsqrt.h b/src/utils/fastsqrt.h index 8ba6f8ce..8da1d354 100644 --- a/src/utils/fastsqrt.h +++ b/src/utils/fastsqrt.h @@ -9,15 +9,16 @@ float fastInvSqrt(float x) { - float xhalf = 0.5f*x; - int i = *(int*)&x; - i = 0x5f375a86- (i>>1); - x = *(float*)&i; - x = x*(1.5f-xhalf*x*x); + union { int i; float x; } tmp; + float xhalf = 0.5f * x; + tmp.x = x; + tmp.i = 0x5f375a86 - (tmp.i >> 1); + x = tmp.x; + x = x * (1.5f - xhalf * x * x); return x; } float fastSqrt(float x) { - return 1.0f/fastInvSqrt(x); + return 1.0f / fastInvSqrt(x); } -- cgit v1.2.3-70-g09d2