[dasher] Revert part of 1faa97 and fix gcc abs() in another way.



commit 8f280fee3d5963d5f4491cac80d759cd306bca3d
Author: Patrick Welche <prlw1 cam ac uk>
Date:   Tue Nov 29 17:17:02 2011 +0100

    Revert part of 1faa97 and fix gcc abs() in another way.
    
    The error message without this fix on gcc 4.5.3 is:
      GameModule.cpp:126:92: error: no matching function for call
      to 'max(Dasher::myint, __gnu_cxx::__enable_if<true, double>::__type)'

 Src/DasherCore/GameModule.cpp |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/Src/DasherCore/GameModule.cpp b/Src/DasherCore/GameModule.cpp
index 21f722e..1dd6887 100644
--- a/Src/DasherCore/GameModule.cpp
+++ b/Src/DasherCore/GameModule.cpp
@@ -113,10 +113,6 @@ void CGameModule::StartWriting(unsigned long lTime) {
   }
 }
 
-#if !defined(TARGET_OS_MAC) && !defined(TARGET_OS_IPHONE)
-static myint abs(myint x) { return (x>0)?x:-x; }
-#endif
-
 void CGameModule::DecorateView(unsigned long lTime, CDasherView *pView, CDasherModel *pModel) {
 
   if (m_dSentenceStartNats == numeric_limits<double>::max())
@@ -125,9 +121,12 @@ void CGameModule::DecorateView(unsigned long lTime, CDasherView *pView, CDasherM
   const myint iNewTarget((m_y1+m_y2)/2);
   m_vTargetY.push_back(iNewTarget);
   bool bDrawHelper=false;
-  
+
+  // gcc 4.5.3 abs(myint) returns __gnu_cxx::__enable_if<true, double>::__type
+  // rather than myint, so max doesn't receive 2 of the same type.
+  myint gcc45_workaround = abs(m_iTargetY-CDasherModel::ORIGIN_Y);
   if (abs(iNewTarget - CDasherModel::ORIGIN_Y) >=
-      max(myint(GetLongParameter(LP_GAME_HELP_DIST)),abs(m_iTargetY-CDasherModel::ORIGIN_Y))) {
+      max(myint(GetLongParameter(LP_GAME_HELP_DIST)),gcc45_workaround)) {
     //needs help - offscreen and not decreasing
     if (m_uHelpStart==std::numeric_limits<unsigned long>::max())
       m_uHelpStart = lTime;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]