Time library fails to compile on Arduino 1.5.7

bperrybap

Well-known member
Paul,
Arduino 1.5.7 ships with avr gcc 4.8.1 which requires that all AVR progmem data be const.
The current DateStrings.cpp in the Time library no longer compiles.
The issue seems to be the declaration for the progmem arrays of pointers.
Not only do the pointers in the array need to be const (which PGM_P takes care of) but the
array itself needs to be const.

It appears that the declarations need an additional const before the array name to make the array itself
const.
I have attached an updated DateStrings.cpp that has been updated.
Once the correct declaration is used, it works with avr gcc 4.8.1 as well
as the older versions of the compiler so it works with IDE 1.5.7 as well as pre IDE 1.5.7

You can read more about this in this arduino forum thread:
http://forum.arduino.cc/index.php?topic=254424.0

--- bill
View attachment DateStrings.cpp
 
It is said here in many places that Teensy / Teensyduino requires Arduino 1.0.x.
Due to beta status of 1.5.x

Have you been able to use 1.5 and libraries?
 
I use many different versions of Teensy products and
and I know that Teensyduino support currently isn't available for 1.5x

While I haven't tried to port teensyduino to 1.5x. I'm sure it wouldn't be that difficult.
I've already got chipkit, and the 1284 core up and running on 1.5x

But I wasn't really referring to Teensduino.

I guess I should have been a bit more clear in the post what I was asking for.

What I'd like is to get the Time library zip image on this page:
https://www.pjrc.com/teensy/td_libs_Time.html
updated to work with 1.5.7
While it is only an issue for 1.5.7, which currently isn't supported
by Teensy yet, eventually it will be supported by Teensy products and in the mean time,
pages like this:
http://playground.arduino.cc/code/time
are directing Arduino users to the PJRC Time library page for an "updated"
version of the Time library.
1.5.7 hasn't been out a week yet, and we have already seen the first questions about
Time library issues with it on the Arduino forum and I'm sure many more will start to follow.
If the Time library were in its own repo I would create a pull request for the updates,
but right now, that doesn't seem to be the case.
I was hoping that it could be updated before too many others stumble across
the issues.

--- bill
 
Paul,
Arduino 1.5.7 ships with avr gcc 4.8.1 which requires that all AVR progmem data be const.
The current DateStrings.cpp in the Time library no longer compiles.

Its good that the Arduino folks are now using a more modern version of gcc for the AVR boards. The ARM boards have been on a more modern version for a while now.

It seems that the Time library is not yet on GitHub so you can't just fork it and make a pull request, but the updated library that you attached will be examined and the changes folded in, I'm sure. Thanks for the bug report,fix, and the link to discussion, too.
 
Can I somehow use a gcc with Teensy 3 that supports C99? I really dislike the absence of C99 support, e.g., struct initializers with named members.
 
Off-topic

Can I somehow use a gcc with Teensy 3 that supports C99? I really dislike the absence of C99 support, e.g., struct initializers with named members.
I'm guessing that there is a reason paul does different C standards for AVR vs ARM builds.
You can change the commandline arguments to anything you want.
You have to modify the the boards.txt file and it will be per board.
Have a look at {installdir}/src/Compiler.java and it should be obvious.

You can enable/disable/modify the -std options for c++0x or g++0x support by adding/modifying a lines like:
teensy31.build.cpp0x=true
teensy31.build.gnu0x=true


You can also add new lines for additional build options by adding lines like:
teensy31.build.option#=YOUR_OPTION

Where # is a digit that is consecutive to any other build option to that board.
And YOUR_OPTION is any option you want -std=??? -DMYDEFINE etc...

1.5x IDE has higher level control of commands and their options in
the platform.txt file.


--- bill
 
Can I somehow use a gcc with Teensy 3 that supports C99? I really dislike the absence of C99 support, e.g., struct initializers with named members.

As others have said, you can edit the boards.txt file to add options. However, you won't be able to use it in your .ino/.pde files to get named initialization, because IIRC, C++ does not have named initialization. You could move your files to a library file, and then use a .c suffix instead of .cpp.

It would be nice if Teeny 3.x and Arduino could both move up to GCC 3.9, and enable C11/C++11 support.

The C++ way to do it is by using a class instead of a struct, and using a constructor to fill in all of the fields. The downside of a constructor is that it is executable code, and it has to run at program startup.
 
Last edited:
The compiler used for ARM-based teensy 3.x is arm-none-eabi-gcc-4.7.2 because the Arduino 1.0.x does not support ARM so there was a free choice. While (for Arduino compatibility) the one used for AVR-based Teensy 2.0 and ++2.0 is the same one Arduino uses, avr-gcc-4.3.2

The one used for Due support (I have the beta 1.5.6-r2 installed) was arm-none-eabi-gcc-4.4.1 until 1.5.7

Arduino 1.5.7 seems to have moved to a newer version of gcc specifically to enable C++11. For example, there was a recent change to enable the String class to use C++11 ranged iterators.

Michael, since these are all 4.x versions i am not understanding your comment about moving up to 3.9
 
I've put this fix on my to-do list.

The Time library is an interesting situation. Officially. Michael Margolis still maintains it.

If Michael doesn't take the lead on this within the next few weeks, I'll update my copy.
 
I've put this fix on my to-do list.

The Time library is an interesting situation. Officially. Michael Margolis still maintains it.

If Michael doesn't take the lead on this within the next few weeks, I'll update my copy.

I should be able to get to this over the coming weekend.

Michael Margolis
 
Someday I'm going to make a great library manager that integrates with the Arduino IDE. At the rate things are going, I may not actually get to work on this until 2016... but I'll do it eventually.

One of the main features will be some sort of distributed online database of all libraries and their versions. I want it to integrate with Arduino's compile process, so a helpful and highly visible warning will appear when an old version of any library is compiled. Ideally, it should have a single-click button right in the console, to update the library to a newer version. Or when the library is the latest known version, the button would turn into a way to instantly submit a bug report containing the complete project source code, including any other libraries in use that might be conflicting.

If only there were many more hours in every day.....
 
I think the issue here is that the Time library zip file on the Time library page:
http://www.pjrc.com/teensy/td_libs_Time.html
Is behind the code in the repo and does not have the update that corrects the AVR progmem declarations.

There were a few folks running into this over on the Arduino forum in the last week or so as well.

--- bill
 
Indeed Bill there were, hence we have a correction to those declarations posted on our website and in a thread here. I was hoping the library would incorporate the changes.
 
If you have already corrected the compile time errors in the library (I just changed two lines) then you have already done it, probably better than I did!
 
Back
Top