error: 'isnan' was not declared in the scope

I have an issue with a sketch that I am working on. The sketch uses the following libraries:

#include <BME280I2C.h>
#include <Wire.h>
#include <SPI.h>
#include <RF24-STM.h>

It is compiled for the “generic STM32F103C series” boards. It compiled fine several weeks ago but I took a break from working on the sketch to do other things. Recently, I got back to the project and when I started the arduino IDE, I got the message that there were library and board updates and, as usual, I installed all the updates for libraries and boards that I use.

When I attempted to compile the sketch, I got the following error:

"D:\Documents\Arduino\libraries\BME280\src\EnvironmentCalculations.cpp:86:28: error: ‘isnan’ was not declared in this scope

if (metric && !isnan(temp) && !isnan(hum))"

Actually, I got serveral of these errors because isnan() is called multiple times in the BME280 library routines.

I went back through the updates and discovered that the issue is associated with an update to the board “STM32F1xx/GD32F1xx boards”. If I revert back to version 2020.5.18 which is the level that I was at when I last worked on this sketch, it compiles with no errors. However, if I reinstall any of the updates for this board (2020.5.26 thru current level 2020.6.17) then I get this compilation error.

I went to the online help link for this board as listed in the board manager (https://www.stm32duino.com/) and created a forum entry (see forum topic “error: ‘isnan’ was not declared in the scope isnan(n)” or link [Solved] error: 'isnan' was not declared in this scope isnan(n); - Arduino for STM32) for more information. The last response that I received on this topic is:
Re: error: ‘isnan’ was not declared in this scope isnan(n);
Post by stevestrong » Fri Jun 19, 2020 7:17 am
This error is only shown with the original 4.8.3 GCC compiler version. Because I use 7.2.1, this was not visible.

The solution is to insert:
#include <math.h>
using namespace std;

before setup().
I just committed a fix in the repo.
Please check out the latest version and let me know if it works.

I have responded to “stevestrong” that the current level 2020.6.17 does not resolve the issue and this his suggestion does not resolve the issue because placing these statements in my base sketch does correct the compile error which occurs in the routines in the library BME280.

I am creating this topic in the arduino forums to document this issue to the general arduino community and to solicit comments on who should resolve this issue and possibly get information on where the gcc/g++ compiler gets installed and configured. Also, if this turns out to be a dependency for future STM32F1xx board manager updates, should not there be some form of dependency checking in the board manager installation process?

I am also interested in information on the gcc/g++ compiler. Is it a single compiler that can compile for different architectures or are there separated gcc/g++ compilers for each architecture? Where are the compiler options configured, etc?

(deleted)

Sorry, isnan in C/C++, according to www.cplusplus.com .

It is isNaN in other languages, such as Java and JavaScript.

:frowning:

Until Arduino decides to release some board with an STM processor, all support for it is third party, including the STM official core. In fact, the official core has really good support from STM. The best way to seek a fix, is to see whether it is a known issue with an existing pull request. Probably there is. Pull requests are the official bug reports.

Your aim of "documenting it for the community" is a little bit of a stretch for an issue like this. It's free open source software. It's a huge project and there are bound to be glitches as the core evolves. It's not like there are full time large teams of software developers beholden to your needs, as you have not purchased a commercial product.

I feel your pain, having experienced issues like this before, but it will be fixed and/or forgotten before 99.999% of the community knows there ever was a problem.

ghstroud:
I just committed a fix in the repo.
Please check out the latest version and let me know if it works.

I have responded to "stevestrong" that the current level 2020.6.17 does not resolve the issue

That's because the fix was made today, so of course you're not going to find it in the release from two days ago. You can follow these instructions to get the latest development version of the platform:

Or you can wait for Dan Drown to do another Boards Manager release.

ghstroud:
should not there be some form of dependency checking in the board manager installation process?

I don't know what you mean by that. Boards Manager already allows the platform author to define the dependencies. Here's the index entry for the 2020.6.17 release:

{
   "version" : "2020.6.17",
   "name" : "STM32F1xx/GD32F1xx boards",
   "boards" : [
      {
         "name" : "Maple Mini"
      },
      {
         "name" : "Maple (Rev 3)"
      },
      {
         "name" : "Maple (RET6)"
      },
      {
         "name" : "Microduino Core STM32 to Flash"
      },
      {
         "name" : "STM Nucleo F103RB (STLink)"
      },
      {
         "name" : "Generic STM32F103C series"
      },
      {
         "name" : "Generic STM32F103R series"
      },
      {
         "name" : "Generic STM32F103T series"
      },
      {
         "name" : "Generic STM32F103V series"
      },
      {
         "name" : "Generic STM32F103Z series"
      },
      {
         "name" : "Generic GD32F103C series"
      }
   ],
   "size" : 9001137,
   "architecture" : "STM32F1",
   "checksum" : "SHA-256:6acb6b71abf81251c267a50f94846c31cb0f3ae6d447b84aa812f6e01a011fbe",
   "toolsDependencies" : [
      {
         "version" : "2020.6.17",
         "name" : "stm32tools",
         "packager" : "stm32duino"
      },
      {
         "version" : "4.8.3-2014q1",
         "name" : "arm-none-eabi-gcc",
         "packager" : "arduino"
      }
   ],
   "url" : "http://dan.drown.org/stm32duino/STM32F1-2020.6.17.zip",
   "category" : "STM32",
   "archiveFileName" : "STM32F1-2020.6.17.zip"
}

This tells the Arduino development software to install the arm-none-eabi-gcc compiler, version 4.8.3-2014q1 packaged by arduino, if it isn't already installed.

More information on this here:
https://arduino.github.io/arduino-cli/latest/package_index_json-specification

Does that answer your question, or did you have some other idea about dependency checking?

ghstroud:
I am also interested in information on the gcc/g++ compiler. Is it a single compiler that can compile for different architectures

Different architectures may use different flavors of GCC. In this case, the arm-none-eabi-gcc compiler is used for ARM core microcontrollers of quite a few different architectures (as the term is used in the world of Arduino boards platforms). Other platforms might use a more architecture-specific compiler. For example, the avr-gcc compiler is only used for the "avr" and "megaavr" Arduino architectures.

aarg:
Until Arduino decides to release some board with an STM processor, all support for it is third party,

They just did. The new Portenta uses the STM32H747XI.