simple code: compiles on 021, fails on 022


I tried to recompile my project with a newer Arduino IDE. Last I compiled it was arduino-021 and it was completely Ok. Now with 022 it fails and error message is very generic and unhelpful :

sketch_mar28a:2: error: expected ',' or '...' before '&' token
sketch_mar28a:2: error: ISO C++ forbids declaration of 'T' with no type

The smallest code snippet that demonstrates this error is:

#include <EEPROM.h>

template <class T> int EEPROM_writeAnything(int ee, const T& value)
    const byte* p = (const byte*)(const void*)&value;
    int i(0);
    for (; i < sizeof(value); ++i)
	  EEPROM.write(ee++, *p++);
    return i;

void setup() {

void loop() {

Can someone explain me what is wrong ? I tried with arduino-022, both win and linux versions.

This is known - it has come up in the last few days, and there is a workaround. Look for recent posts on this subject. Here's one I googled earlier,45887.0.html

Thanks! With a mentioned workaround project compiles again.

What makes me a little bit suspicious is that its size reduced from 6558 bytes to 6068 bytes. Probably, due to optimization mentioned in 022 changelog:

"* Refactoring core to use register-based, not CPU-based, #ifdefs"