Example sketch does not compile

butchalline
Posts: 14
Joined: Sat Oct 14, 2017 2:05 pm

Example sketch does not compile

Postby butchalline » Tue Apr 20, 2021 8:13 pm

Sketch is RTClib > ds1307 which does date and time functions using a DS1307 RTC connected via I2C and Wire lib

After compiling, I get:
Arduino: 1.8.12 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

C:\Users\ButchHam\Documents\Arduino Butch code\libraries\RTClib\RTClib.cpp: In constructor 'DateTime::DateTime(const char*, const char*)':

C:\Users\ButchHam\Documents\Arduino Butch code\libraries\RTClib\RTClib.cpp:136:70: error: operation on '((DateTime*)this)->DateTime::m' may be undefined [-Werror=sequence-point]

case 'J': m = date[1] == 'a' ? 1 : m = date[2] == 'n' ? 6 : 7; break;

^

C:\Users\ButchHam\Documents\Arduino Butch code\libraries\RTClib\RTClib.cpp: In constructor 'DateTime::DateTime(const __FlashStringHelper*, const __FlashStringHelper*)':

C:\Users\ButchHam\Documents\Arduino Butch code\libraries\RTClib\RTClib.cpp:161:70: error: operation on '((DateTime*)this)->DateTime::m' may be undefined [-Werror=sequence-point]

case 'J': m = buff[1] == 'a' ? 1 : m = buff[2] == 'n' ? 6 : 7; break;

^

cc1plus.exe: some warnings being treated as errors

exit status 1
Error compiling for board ESP32 Dev Module.


Board is ESP32 dev module (wroom)
Arduino IDE is 1.8.12
Sketch compiles and works as expected with UNO

Any and all help appreciated, thanks

tinker
Posts: 5
Joined: Tue Oct 27, 2020 12:09 am

Re: Example sketch does not compile

Postby tinker » Tue Apr 20, 2021 11:25 pm

You've probably tried these already, but if not, it might help a little.

While this might not fix things for you, in my experience, running working Arduino Code on an ESP32 usually works fine (after tweaking GPIOs). Sometimes you need to also add #include <Arduino.h> or #include <SPI.h> or #include <Wire.h>, or all of them at the very least!

You didn't mention what the filename is of your sketch... ?? Does it end with .c ?? If so, rename it to .cpp. This has caught me out a few times when I started out.

Other than that, you might want to add some more info. It might be the libraries (#include lines in your sketch) aren't quite compatible with your board too, in which case, you'll have to dig deep, and it won't be for the faint-hearted / undetermined / those who swerve a challenge!

Good luck!

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: Example sketch does not compile

Postby ESP_Sprite » Wed Apr 21, 2021 1:53 am

In this case, the library is just written shoddily and the compiler refuses to compile the crap in it:

Code: Select all

m = buff[1] == 'a' ? 1 : m = buff[2] == 'n' ? 6 : 7;
It's entirely unclear what m is supposed to be here, as it's assigned twice to two different values in one operation.

butchalline
Posts: 14
Joined: Sat Oct 14, 2017 2:05 pm

Re: Example sketch does not compile

Postby butchalline » Wed Apr 21, 2021 2:34 pm

Thank you Tinker and Sprite. Still no joy yet.

This library was written in 2016 by JeeLabs (aka J.C. Wipple) who usually does good work.

I am just a hobbyist and certainly not a geek, but it seems that the problem lies with some conversions or interpretations between the Arduino IDE and the ESP32 dev board. There are several examples in this library and they all work with a UNO, but none of the examples work with the ESP dev board.

Can you recommend any other IDE's or RTC sketches that I could explore?

Thanks
Butch

butchalline
Posts: 14
Joined: Sat Oct 14, 2017 2:05 pm

Re: Example sketch does not compile

Postby butchalline » Wed Apr 21, 2021 3:09 pm

Update: I was using ver. 1.2 of the library. Updated to ver. 1.13 and all works as expected.

tinker
Posts: 5
Joined: Tue Oct 27, 2020 12:09 am

Re: Example sketch does not compile

Postby tinker » Wed Jul 14, 2021 9:50 pm

Thanks for posting your resolution! And well done for figuring it out!

My choice of IDE is VSCode with the PlatformIO plugin enabled. Take your time with it, as it will reap untold rewards with your productivity, and help you make more complex projects with varying chips, as time goes on. It's my go-to IDE now. Arduino IDE is great too, so if it works for you, don't change. But do invest bursts of time experimenting with VS Code, especially if you're playing with more than one board and more than one architecture.

I'm sure you're already doing this, so for the benefit of others in different positions to you, please check out YouTube and blog posts to help you learn. I'm not an expert, yet I've been working professionally for many many years with software in various languages and platforms. It's impossible to stop learning new things. There are more ways to learn now than there has ever been. There are also many opinions too. Everyone has an opinion. Don't be blinded by one expert's perspective or experience. Form your own opinion. and be open to changing it, if it makes you a better person, and then change it again, even if it goes against what you've learned. Eventually you'll learn that it's okay to change your mind!

Who is online

Users browsing this forum: No registered users and 40 guests