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 Project will not compile in VS 2013 but will in Arduino IDE (Read 3084 times)
IanS
Junior Member
**
Offline


Posts: 14
Joined: Jun 29th, 2016
Project will not compile in VS 2013 but will in Arduino IDE
Aug 5th, 2016 at 8:17pm
Print Post  
Hi all,

I have a project I am working on that will not compile in VM + VS2013 but compiles just fine in the Arduino IDE. I've stripped out everything extra leaving only the essentials and I am still getting all these crazy errors. I've tried creating a new clean solution and nothing seems to work. I've pasted the error and relevant code below. I am using Arduino IDE 1.6.10. I was using this code in another project, It was implemented in a class using .H and .CPP files which seems to keep the issue away?


Code (C++)
Select All
Compiling 'EEPROMTest' for 'Arduino Pro or Pro Mini w/ ATmega328 (5V, 16 MHz)'
EEPROMTest.ino:5:19: error: 'stats' was not declared in this scope
:int magicFunction(stats temp)
EEPROMTest.ino:In function 'int magicFunction(stats)
EEPROMTest.ino:23:29: error: 'int magicFunction(stats)' redeclared as different kind of symbol
:int magicFunction(stats temp)
EEPROMTest.ino:noteĀ  previous declaration 'int magicFunction
:int magicFunction(stats temp)
Error compiling project sources 



Here is the code that generates this error. I have stripped out all the extra stuff to show how easily it errors for me. This code will compile and upload 100% find if I do it directly in the arduino IDE.....

Code (C++)
Select All
union stats
{
	typedef struct boxData1
	{
		int var1;
	};
	boxData1 data;
	int array[(sizeof(boxData1) / 2)];
};
stats allData;


void setup()
{
	Serial.begin(9600);
}

void loop()
{

}

int magicFunction(stats temp)
{


} 



Thanks in advance!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Project will not compile in VS 2013 but will in Arduino IDE
Reply #1 - Aug 6th, 2016 at 3:14pm
Print Post  
Hi,

Until recently arduino couldn't handle user types in method signatures because prototypes were inserted in an incorrect position. The new system is slower so we are going to implement after working on some faster ways of achieving the same result.

This only applies to automatic prototype generation which only happens for .ino files. Cpp source codes always have them included bu the author. 

BUT you can tell visual micro where a prototype should be then it won't try to insert one automatically in the wrong position

Notice in this example I have added a prototype for the magicFunction method before "stats" is used but after it has been defined. 

Code
Select All
nion stats
{
	typedef struct boxData1
	{
		int var1;
	};
	boxData1 data;
	int array[(sizeof(boxData1) / 2)];
};
stats allData;

// prototypes
int magicFunction(stats temp);

void setup()
{
	Serial.begin(9600);
}

void loop()
{

}

int magicFunction(stats temp)
{


}  

  
Back to top
IP Logged
 
IanS
Junior Member
**
Offline


Posts: 14
Joined: Jun 29th, 2016
Re: Project will not compile in VS 2013 but will in Arduino IDE
Reply #2 - Aug 8th, 2016 at 11:42am
Print Post  
Awesome, that fixed it. Out of curiosity, is there somewhere in the release docs or somewhere else that this issue was mentioned? Given that I have the latest arduino IDE installed I would think it would conform to that.

Thanks.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Project will not compile in VS 2013 but will in Arduino IDE
Reply #3 - Aug 8th, 2016 at 12:02pm
Print Post  
Visual micro will shortly move to the new system so any docs will be confusing because search engines tend to become out of date so quickly.

However arduino only moved to it a few months ago so there should be more docs talking about the old way rather than the new way. not that that helps but it's part of the arduino legacy.

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint