Round() Function Error - Web IDE [SOLVED]

Has anyone implemented math.h in their apps; or more specifically, round()? I Copied math.h from my arduino libraries and pasted it into the web IDE, labeling it math.h; however, when I go to verify my code I get this response:

math.h:440:8: error: expected unqualified-id before 'double’
math.h:440:8: error: expected ‘)’ before 'double’
math.h:440:8: error: expected ‘)’ before ‘double’

The line it’s referring to is the round() function which is written as:

double round (double __x) __ATTR_CONST__;

All of the other functions seem fine, but this one, the one I need reports an error.

Thanks for the help.

gaudsend, no need to copy the arduino library. Just put #include "math.h" at the top of your file and the web IDE will include the STM32 version of the math library. :smile:

1 Like

@peekay123 Thank you very much! Works perfectly now :smile:

Hi @gaudsend

The library math.h is already there for you if you just

#include <math.h>

Was that not working for you in some way? I don’t think that using the Arduino version is going to be a good idea.

I didn’t know math.h was already available. I think the issue was because I had the arduino version of the library pasted into the web IDE and when I used #include “math.h” it was including both…or perhaps the arduino one wasn’t entirely compatible. Regardless, I removed the pasted library and it works great.