Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic template <class T>: error: 'T' does not name a type (Read 2877 times)
ioan
Newbies
*
Offline


Posts: 1
Joined: Mar 9th, 2016
template <class T>: error: 'T' does not name a type
Mar 9th, 2016 at 5:58pm
Print Post  
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:

Code (C++)
Select All
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:

Code
Select All
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.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12138
Location: United Kingdom
Joined: Apr 10th, 2010
Re: template <class T>: error: 'T' does not name a type
Reply #1 - Mar 9th, 2016 at 7:11pm
Print Post  
Hi,

Historically the def would need to be in a .h

Recent updates to the arduino ide allow for these in .ino code but also causes issues for some users. Visual micro will do the same once the new system stabalizes
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint