Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include math.h #49

Merged
merged 1 commit into from
Dec 30, 2020
Merged

Include math.h #49

merged 1 commit into from
Dec 30, 2020

Conversation

jdavid
Copy link
Contributor

@jdavid jdavid commented Oct 24, 2020

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

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
@nseidle
Copy link
Member

nseidle commented Dec 29, 2020

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?

@jdavid
Copy link
Contributor Author

jdavid commented Dec 30, 2020

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.

@jdavid
Copy link
Contributor Author

jdavid commented Dec 30, 2020

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.

@nseidle
Copy link
Member

nseidle commented Dec 30, 2020

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.

@nseidle
Copy link
Member

nseidle commented Dec 30, 2020

Thanks again!

@nseidle nseidle merged commit a97663c into sparkfun:master Dec 30, 2020
jdavid added a commit to spectraphilic/wsn_riot that referenced this pull request Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SparkFunBME280.cpp:410:37: error: ‘pow’ was not declared in this scope
2 participants