0

I am using GCC 5.4 and getting 'isnan' was not declared in this scope error. I found <cmath> hides isnan in <math.h> in C++14 / C++11?.

but I have to keep the GCC version, without modifying the source which uses isnan, and C++14 standard. so I want to know any trick to solve it.

for example: define isnan=std::isnan as compile -D argument?

JustWe
  • 4,250
  • 3
  • 39
  • 90
  • Consider compiling [GCC 10](http://gcc.gnu.org/) from source code, or try using the [Clang](http://clang.llvm.org/) C++ compiler – Basile Starynkevitch Feb 05 '21 at 07:35
  • Hi @BasileStarynkevitch my source code is for compiling so old low-leve driver which require GCC version >= 5. – JustWe Feb 05 '21 at 07:40
  • But you could download the source code of [GCC](http://gcc.gnu.org/) and compile it. Since GCC is [free software](https://www.gnu.org/philosophy/free-sw.en.html), you technically can compile it (or install [Debian](https://debian.org/) on your compuiter). See [this draft report](http://starynkevitch.net/Basile/bismon-doc.pdf). Current version of [GCC](https://gcc.gnu.org/) is -in febr. 2021- GCC 10. Your GCC 5.4 is not supported today – Basile Starynkevitch Feb 05 '21 at 07:42
  • Discuss with your manager the opportunity to upgrade your GCC compiler. Upgrade to GCC 10 and invoke it as `g++ -Wall -Wextra -g` at least – Basile Starynkevitch Feb 05 '21 at 07:46
  • @BasileStarynkevitch ok, I see, Thank you. – JustWe Feb 05 '21 at 07:49
  • You could also contact some companies selling support on GCC 5 (I know people from [Adacore](https://www.adacore.com/)...) This is expensive! Consider also using [Frama-C](http://frama-c.com/) or the [Clang static analyzer](https://clang-analyzer.llvm.org/) – Basile Starynkevitch Feb 05 '21 at 07:51
  • 1
    `without modifying the source which uses isnan, and C++14 standard.` is that really no option? It is not uncommon for package managers to include patch files for the source files as a quick fix if the upstream source code isn't fully compatible with the distribution. So creating a diff file to patch in the corresponding headers in the build process looks like a durable option. (It for sure might be a license problem depending one what exactly you do) – t.niese Feb 05 '21 at 08:25

0 Answers0