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 Cant compile with templates? (Read 494 times)
cagri53
Newbies
*
Offline


Posts: 1
Joined: Jul 9th, 2020
Cant compile with templates?
Jul 9th, 2020 at 7:38am
Print Post  
Hello to all,

I have written a very basic code in atmel studio Vmicro like;
Code (C++)
Select All
template <typename T>
void serial_send(T message)
{
   Serial.print(message);
}

void setup()
{
	Serial.begin(9600);
	serial_send("Hello World");
}

void loop()
{

}
 



After I tried to compile this, I got errors like
Quote:

Error            2:18: error: variable or field 'serial_send' 
Error            2:18: error: 'T' was not declared in this 


But I can compile with Arduino IDE succesfully by opening ino file that this project created. 
What is the problem?
« Last Edit: Jul 9th, 2020 at 7:39am by cagri53 »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Online


Posts: 2145
Joined: Feb 13th, 2019
Re: Cant compile with templates?
Reply #1 - Jul 9th, 2020 at 10:38am
Print Post  
Thanks for the report and detail.

This is an issue with the automatic prototype generation in Visual Micro.

We will investigate further, and in the meantime, you can add the below prototype above the first line:-
Code
Select All
template <typename T>void serial_send(T message); 



Then add a Local Board.txt to the project (Right Click project in Solution Explorer, Add > Local Board.txt), and add the below line to that file:-
Code
Select All
vm.ctags=false 



This should allow it to build while we investigate the full resolution further.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint