Re: Patch for olethros on Fedora

Jeremy Bennett <[email protected]> Fri, 12 May 2017 12:28:28 +0100
Newsgroups gmane.games.torcs.devel
Organization Embecosm
Message-ID <[email protected]>
On 09/05/17 19:53, Bernhard Wymann wrote:
> Hi Jeremy
> 
> Using std:: here is not a good idea (because of some other compiler
> and linking issues), could you provide a fix which uses the c
> isnan?
> 
> What is a bit weird that we use the isnan in various places, what
> makes this special location for fedora (the others seem to work for
> you)?

Hi Bernhard,

I see that by coincidence Markus Koschany hit the same thing with
Debian and came up with the same solution on the same day.

G++ 6.x defaults to C++11, which requires isnan is explicitly
qualified as std::isnan. As more distributions adopt GCC 6.x, this
will become a wider issue.

The alternatives are:

1. keep the code at C++98, in which case the standard CXXFLAGS need to
have std=c++98 or std=gnu++98.

2. compile with gcc rather than g++

3. include math.h rather than cmath

So why does only this file barf. The following files in the src
directory also use isnan:

src/tools/accc/ac3dload.cpp
src/libs/learning/policy.cpp
src/modules/simu/simuv3/simu.cpp
src/modules/simu/simuv3/collide.cpp
src/modules/simu/simuv2/simu.cpp
src/modules/simu/simuv2/collide.cpp
src/drivers/human/human.cpp
src/drivers/olethros/driver.cpp
src/drivers/olethros/geometry.cpp

There seem to be two reasons.

1. Some of these are compiled with gcc, rather than g++, so will pick
up C semantics, without namespaces.

2. Some include math.h, rather than cmath, so again follow pure C
semantics.

The example I hit was the only one to both use g++ for compilation and
include from <cmath>.

This is a new code base to me, so I leave to you to decide which
approach you prefer.

If it helps, in other C++ projects personally I have been moving to
C++11, C++14 and even C++17, since the smart pointer functionality
does a lot to get rid of memory leaks.

Best wishes,


Jeremy

> 
> Kind regards
> 
> Bernhard
> 
> On 09.05.2017 18:40, Jeremy Bennett wrote: Found compiling for
> Fedora 25:
> 
>>>> $ uname -a Linux buzz 4.9.14-200.fc25.x86_64 #1 SMP Mon Mar
>>>> 13 19:26:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
> 
> inan needs to be qualified as std:inan. Diff:
> 
> $ cvs diff src/drivers/olethros/geometry.cpp Index:
> src/drivers/olethros/geometry.cpp 
> ===================================================================
>
> 
RCS file: /cvsroot/torcs/torcs/torcs/src/drivers/olethros/geometry.cpp,v
> retrieving revision 1.9 diff -r1.9 geometry.cpp 373c373 <
> if (isnan(r)) { ---
>>>> if (std::isnan(r)) {
> 
> ChangeLog entry:
> 
> * src/drivers/olethros/geometry.cpp (EstimateSphere): Qualify inan
> as std::inan.
> 
> Also filed as support request 12.
> 
> HTH,
> 
> 
> Jeremy
> 
> -- Tel:     +44 (1590) 610184 Cell:    +44 (7970) 676050 SkypeID:
> jeremybennett Twitter: @jeremypbennett Email:
> [email protected] Web:     www.embecosm.com PGP key:
> 1024D/BEF58172FB4754E1 2009-03-20
>> 
>> ------------------------------------------------------------------------------
>>
>>
>> 
Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot 
>> _______________________________________________ Torcs-devel
>> mailing list [email protected] 
>> https://lists.sourceforge.net/lists/listinfo/torcs-devel
>> 
> 

-- 
Tel:     +44 (1590) 610184
Cell:    +44 (7970) 676050
SkypeID: jeremybennett
Twitter: @jeremypbennett
Email:   [email protected]
Web:     www.embecosm.com
PGP key: 1024D/BEF58172FB4754E1 2009-03-20

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot