I'm trying to compile some code that compile fine in Arduino IDE, in Visual Studio with support for Arduino (Visual Micro). This is the code with problems:
template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
return i;
}
template <class T> int EEPROM_readAnything(int ee, T& value)
{
byte* p = (byte*)(void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
The error I'm getting is:
app.ino:43:40: error: 'T' does not name a type
:int EEPROM_writeAnything(int ee, const T& value)
app.ino:43:43: error: ISO C++ forbids declaration of 'value' with no type [-fpermissive]
Can someone please point me in the right direction?
Thanks.
template <class T> class value;