| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
SparkFunBME280.cpp uses math functions pow, log and log10. This produces errors such as "pow was not declared in this scope". Found this while packaging this library for RIOT-OS. The library works with Arduino because math.h is included somewhere else. But I think it's better or more correct to include the headers for the functions used. Fixes sparkfun#48
|
Shouldn't this be included in the header that includes the compile guards? Yes, math.h should have it's own guards but it's best practice to put math.h inside SparkFunBME280.h, no? |
Sorry, something went wrong.
|
A quick search for best practice makes me think it's the opposite: include where it's used, e.g. https://stackoverflow.com/a/3002124/9055637 But if you prefer I will move the include to the header file. |
Sorry, something went wrong.
|
e.g. in my cpp file I have: #include <SparkFunBME280.h> If #include <math.h> is in the header file then math.h will be included in my cpp file, increasing a little bit the work the compiler has to do. |
Sorry, something went wrong.
|
I stand corrected! Thank you for the education. It's a simple change but I'll test this out with the other PRs later this week. |
Sorry, something went wrong.
|
Thanks again! |
Sorry, something went wrong.
No need patching anymore, sparkfun/SparkFun_BME280_Arduino_Library#49
| Back | FazBrowse Home | New Git URL |
SparkFunBME280.cpp uses math functions pow, log and log10. This produces
errors such as "pow was not declared in this scope". Found this while
packaging this library for RIOT-OS.
The library works with Arduino because math.h is included somewhere
else. But I think it's better or more correct to include the headers for
the functions used.
Fixes #48