"Reading and Writing Data Structures to EEPROM" and Arduino 22

Hello,

I have successfully used the “Reading and Writing Data Structures to EEPROM” sketch from Playground with arduino IDE 21.

Here are the functions I use
template int EEPROM_WriteElement(byte * ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
int i, j;
j = p-ee;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(j++, *p++);
return i;
}

template int EEPROM_ReadElement(byte * ee, T& value)
{
byte* p = (byte*)(void*)&value;
int i;
int j;
j = p-ee;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(j++);
return i;
}

Yersteday, I have made the upgrade to Aduino IDE 22, and Surprise, my code could not compile

Here are the messages I’ve got
FuzzyMonitor:-1: error: expected ‘,’ or ‘…’ before ‘&’ token
FuzzyMonitor:-1: error: ISO C++ forbids declaration of ‘T’ with no type
FuzzyMonitor:-1: error: ‘T’ has not been declared

Do somebody have an idea ?

Thanks

Do somebody have an idea ?

Yes, version 22 doesn't handle templete build correctly. Solution is to put templete code in a tabbed window and include it in main sketch:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293801796

Hi,

I have done the modification and I am now able to compile successfully my code .

It would be great to have the root cause of such issue. I have not retrieved it in the revisions file.

Missing or side effect ? That is the question

Nevetheless, thanks