Skip to content

conflict between math.h and cmath #318

Closed

Description

@talismanbrandi

#include <math.h>

Hi,

TMath.h contains an inclusion of cmath. Including math.h after including TMath.h seems unnecessary. Also, it creates an error with some compilers, e.g. GCC 7.3.0.

In file included from BCMath.cxx:21:0:
/Users/ayanpaul/opt/local/include/c++/7.3.0/math.h:66:12: error: ‘constexpr bool std::isnan(double)’ conflicts with a previous declaration
using std::isnan;
^~~~~
In file included from BCMath.cxx:17:0:
/Users/ayanpaul/opt/local/include/TMath.h:407:19: note: previous declaration ‘int isnan(double)’
extern int isnan(double);

The code compiles just fine without the inclusion of math.h.

thanks!
Ayan

Activity

  1. oschulz commented on Apr 7, 2019

    @oschulz
    Member

    Thanks for reporting this! We should indeed #include <cmath>. It should be included explicitly though, we shouldn't rely on indirect includes.

  2. talismanbrandi commented on Apr 8, 2019

    @talismanbrandi
    ContributorAuthor

    Thanks for looking into this. Including cmath indeed solves the problem the way you want to.

  3. fredRos commented on Apr 9, 2019

    @fredRos
    Contributor

    @oschulz Would be great to use g++7.3 in our automated testing to really make sure this problem is fixed. Who can open a PR for the fix itself?

  4. fredRos commented on Apr 9, 2019

    @fredRos
    Contributor

    I guess we can update our ubuntu container to use the latest g++ like this

    GCC 8.1.0 on Ubuntu 14.04 & 16.04 & 18.04:
    
    sudo apt-get update -y &&
    sudo apt-get upgrade -y &&
    sudo apt-get dist-upgrade -y &&
    sudo apt-get install build-essential software-properties-common -y &&
    sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y &&
    sudo apt-get update -y &&
    sudo apt-get install gcc-8 g++-8 -y &&
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-8 &&
    sudo update-alternatives --config gcc
    
    select gcc-8
    

    from https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91

  5. added 2 commits that reference this issue on Apr 9, 2019
  6. added a commit that references this issue on Apr 10, 2019
  7. oschulz commented on Apr 10, 2019

    @oschulz
    Member

    Closed by #321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions