-
Notifications
You must be signed in to change notification settings - Fork 4
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
Error on compilation for <cstdint> #1
Comments
Best regards, |
Dear @terrillmoore , I am using Arduino IDE 1.8.9 to compile the example code. Have you tested it before on Arduino? |
That's exactly what I use. I have not tested with 8-bit Arduino, but I test all the time with ARM. This is a defect in the Arduino library; they're not likely to fix it. The workaround is to detect AVR, then #include <stdint.h> and name things. So for example: #ifdef AVR // or whatever -- check the compiler docs, I don't know the standard way to check this offhand
# define NO_CSTDINT 1 // AVR arduino has no <cstdint>; but we're coding to portable C++. So substitute.
#endif
// unless we know otherwise, use the compiler's <cstdint>
#ifndef NO_CSTDINT
# include <cstdint>
#else
// no <cstdint> -- make sure std:: contains the things we need.
# include <stdint.h>
namespace std {
using ::int8_t;
using ::uint8_t;
using ::int16_t;
using ::uint16_t;
using ::int32_t;
using ::uint32_t;
}
#endif (This is what boost does, https://github.com/vancegroup/arduino-boost/blob/master/boost/cstdint.hpp) Since I don't use AVR, I've got no way to test, though I could of course compile. But compilation doesn't really count. Feel free to submit a working pull request. |
I applied proposed changes to
Then, I changed the board to MKRFox1200 which is running on Atmel SAMD21 (based on ARM 32bit architecture). Still, I couldn't compile the code due to the same errors as above. Reverting changes on |
Sorry you're having problems. It works for me. Sounds like the compilers in your packages don't support more recent C++. It works for me with STM32 and the compilers I have. I don't have a lot of time to look at this; if you're feeling brave, try changing the if's to equivalent static constexpr float celsiusBias(float t) { return t + 40.0f; }
// convert Celsius temperature to raw format.
static constexpr std::uint16_t celsiusToRawT(float t)
{
return (celsiusBias(t) < 0.0f ? 0 :
celsiusBias(t) > 165.0f ? 0xFFFCu :
(std::uint16_t) ((t / 165.0f) * float(0xFFFC));
}
// convert RH as percentage to raw format.
static constexpr std::uint16_t percentRHtoRaw(float rh)
{
return (rh > 100.0) ? 0xFFFCu :
(rh < 0.0) ? 0 :
(std::uint16_t) (float(0xFFFC) * (rh / 100.0));
} |
@nimasaj branch https://github.com/mcci-catena/MCCI-Catena-HS300x/tree/issue1 compiles correctly for AVR. I have no way of knowing if it works, but if it works for you, I'll merge onto head. There was one additional problem; in AVR, |
@terrillmoore Thanks for fixing compilation issues. Unfortunately, the driver is not working on Arduino pro mini.
|
@nimasaj i make a simple HS300x library here k2biru/HS300xlib using arduino Wire Library. |
@k2biru It's working fine with small modifications. There were typos on type uint8_t that I proposed in your repository. |
can confirm the issue 1 branch is working correctly for |
Hi @Shiny380, I have not tested. I do have a substitute for |
Thanks for sharing your library. However, I get error on compiling it for Arduino pro mini (328P-3,3V) with following errors:
It points to line 20,
#include <cstdint>
, inCatena-HS300x.h
file. Could you please share missing library/files?The text was updated successfully, but these errors were encountered: