Library error: Time.h (SOLVED)

In IDE 1:1.0.5+dsfg2.2 (on a Linux laptop), I get the following error:

In file included from /home/mint/sketchbook/libraries/Time/DateStrings.cpp:10:0:
/home/mint/sketchbook/libraries/Time/DateStrings.cpp:18:18: error: variable ‘monthStr1’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
char monthStr1[] PROGMEM = "January";

This error is repeated for each month name and day name, plus two more times for strings.

I do not get this error in when I compile in 1.6.4, using the same libraries. It's beyond me to understand why the earlier complier sees the month/day names as variables and the 1.6.4 version does not. Have I missed including some library in my 1.0.5 install?

I'd just use 1.6.4, but currently it has problem uploading (another topic).

In 1.6.x you have to say:

const char monthStr1[] PROGMEM = "January";

The newer compiler wants to make sure you know that data in PROGMEM cannot be changed/overwritten.

John, exactly the right concept, except it is the older compiler that is calling out the error.

I took the time to look at the code in DateStrings.cpp and it definitely defines the months as constants:

// the short strings for each day or month must be exactly dt_SHORT_STR_LEN
#define dt_SHORT_STR_LEN  3 // the length of short strings

static char buffer[dt_MAX_STRING_LEN+1];  // must be big enough for longest string and the terminating null

const char monthStr0[] PROGMEM = "";
const char monthStr1[] PROGMEM = "January";
const char monthStr2[] PROGMEM = "February";
const char monthStr3[] PROGMEM = "March";
const char monthStr4[] PROGMEM = "April";
const char monthStr5[] PROGMEM = "May";
const char monthStr6[] PROGMEM = "June";
const char monthStr7[] PROGMEM = "July";
const char monthStr8[] PROGMEM = "August";
const char monthStr9[] PROGMEM = "September";
const char monthStr10[] PROGMEM = "October";
const char monthStr11[] PROGMEM = "November";
const char monthStr12[] PROGMEM = "December";

Any other comments on why the compiler doesn't see this?

Dr_Quark:
Any other comments on why the compiler doesn't see this?

My first guess would be that you have two files called "DateStrings.cpp" and the wrong one (the older one without the 'const') is being used.

Your 1.0.5 IDE came from your Linux distro's repository. It is unlikely that it has the same compiler and toolchain that Arduino furnished. They will have "improved" things by using the latest avr-gcc release. In the IDE turn on verbose output (File/Preferences) and you can see which compiler they are using. If you want the old compiler use the tarball from:

This fixes the source code:
DateStrings.cpp

Line 41.
From: PGM_P monthNames_P[] PROGMEM =
To: PGM_P const monthNames_P[] PROGMEM =

Line 58.
From: PGM_P dayNames_P[] PROGMEM =
To: PGM_P const dayNames_P[] PROGMEM =

Line 59.
From: char dayShortNames_P[] PROGMEM =
To: const char dayShortNames_P[] PROGMEM =

Thanks, TF.

There must be several versions of DateStrings.ccp circulating. None of my copies had anything like you posted at those line numbers, or even within a few lines, plus or minus. But it did get me thinking. I had several copies that had "const" in the variable declaration lines, but not in the copy that was in the library.

Cleaned up all my libraries, got the new version of DateStrings.ccp in the Time.h library, and, viola, compilation proceeded without error.