icculus / Serious-Engine

An open source version of a game engine developed by Croteam for the classic Serious Sam games.
GNU General Public License v2.0
165 stars 23 forks source link

fix compilation errors with gcc 6.1.1 on Arch Linux #50

Closed Manuel-K closed 8 years ago

Manuel-K commented 8 years ago

I needed to make these changes to compile the project with gcc 6.1.1 on Arch Linux.

xDShot commented 8 years ago

Works for me, thanks.

DanielGibson commented 8 years ago

this breaks compilation on my system, at least with clang (haven't tried gcc).

floor() and log10() return double, why would you change the other argument to float (2.0f instead of 2.0) then? Or, why does gcc 6.1.1 not like the original code? does it use some overloaded version of floor() that also supports float or something like that?

Maybe floorf() and log10f() should be used?

Manuel-K commented 8 years ago

Very strange.

They do return a float on my system which makes the template explode. Your right, it does seems strange. floor and log10 should return doubles. I only looked at the error message when I made this fix.

I've just compiled it with clang and it does work without problems. If I revert the changes, it even breaks compilation with clang:

/somewhere/Serious-Engine/Sources/EntitiesMP/Player.es:5384:21: error: no matching function for call to 'ClampDn'
FLOAT fTimeDelta  = ClampDn  (floor  (m_tmEstTime ) - floor  (tmLevelTime ) , 0.0);
                    ^~~~~~~
/somewhere/Serious-Engine/Sources/./Engine/Math/Functions.h:85:13: note: candidate template ignored: deduced conflicting types for parameter 'Type'
      ('float' vs. 'double')
inline Type ClampDn( const Type x, const Type dnlimit)