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 Strange Visual Micro compile errors while Arduino IDE compiles normally? (Read 4353 times)
ikt
Newbies
*
Offline


Posts: 3
Joined: Aug 8th, 2017
Strange Visual Micro compile errors while Arduino IDE compiles normally?
Aug 8th, 2017 at 1:23pm
Print Post  
Using the latest Visual Micro on Visual Studio 2017, and Arduino IDE 1.8.3.

Using this fork of StandardCplusplus. Target platform is a Pro Micro.

In the Arduino IDE, the project compiles without any problems or warnings, and it runs normally. In Visual Micro, there are no syntax errors in the IDE, but I get a range of strange errors:

Code
Select All
Compiling 'keypad' for 'Arduino/Genuino Micro'

keypad.ino: 3:19: error: 'MacroType' was not declared in this scope
   Macro createMacro(MacroType macro)

keypad.ino: 6:16: error: variable or field 'playMacro' declared void
   void playMacro(MacroType nextMacro)

keypad.ino: 6:16: error: 'MacroType' was not declared in this scope

keypad.ino: In function Macro createMacro(MacroType)

keypad.ino: 47:34: error: 'Macro createMacro(MacroType)' redeclared as different kind of symbol
Error compiling project sources
   Macro createMacro(MacroType macro) {
Build failed for project 'keypad'
keypad.ino:3: note  previous declaration Macro createMacro
   Macro createMacro(MacroType macro)

keypad.ino: In function void playMacro(MacroType)

keypad.ino: 244:37: error: no match for call to '(Macro) (MacroType&)
   Macro macro = createMacro(nextMacro)
 



keypad.ino: 3:19: error: 'MacroType' was not declared in this scope
Line 3 is #include <vector>?

keypad.ino: 6:16: error: variable or field 'playMacro' declared void
Actual line: #include "Macro.h"
Not sure what it wants here, as playMacro is at line 243

keypad.ino: 6:16: error: 'MacroType' was not declared in this scope
Actual line: #include "Macro.h"
Yeah, MacroType is defined below, but Macro.h doesn't have anything to do with the MacroType enum. 

keypad.ino: 47:34: error: 'Macro createMacro(MacroType)' redeclared as different kind of symbol
It wasn't declared before?

keypad.ino:3: note  previous declaration Macro createMacro
Why does it go back again?

keypad.ino: 244:37: error: no match for call to '(Macro) (MacroType&)
Not sure what's going on any more.

This problem started when I made a MacroType enum (to get rid of magic numbers/IDs), but the same source is compiled by the Arduino IDE. Closing and re-opening Visual Studio, switching between release and debug builds didn't change anything.

I attached the source code.
« Last Edit: Aug 8th, 2017 at 1:27pm by ikt »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12186
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Strange Visual Micro compile errors while Arduino IDE compiles normally?
Reply #1 - Aug 8th, 2017 at 1:32pm
Print Post  
Hi,

Before I investigate please try this update

https://1drv.ms/u/s!AsT00oFsGAmRkcdvRyZ4AtDKAeG_mQ


The update ensures the sketch project code is linked before any library code. This was a bug in previous versions and might also be the cause of your issue. Only affects people who redefine lib code.

Thanks
  
Back to top
IP Logged
 
ikt
Newbies
*
Offline


Posts: 3
Joined: Aug 8th, 2017
Re: Strange Visual Micro compile errors while Arduino IDE compiles normally?
Reply #2 - Aug 8th, 2017 at 1:46pm
Print Post  
Hi,

It's installed, but the build results/errors are the same.

Thanks for the quick reply!

Update
Huh, interesting.
Check the generated keypad.cpp:

Code
Select All
#include <Arduino.h>
#include <Keyboard.h>
#include <StandardCplusplus.h>
#include <vector>

#include "KeyInfo.h"
#include "Macro.h"


Macro createMacro(MacroType macro);
//
bool debounce(unsigned long t_now, unsigned long t_prev);
void playMacro(MacroType nextMacro);
//

// Variables and constants

enum class MacroType {
	HelloWorld,
	CRTL_ALT_DEL,
	Admin_CMD,
	WinMin,
	WinMax,
	WinLeft,
	WinRight,
};
// rest of code (function implementations)
 



Looks like Visual Micro makes function prototypes, but puts it on top. Types declared after that aren't picked up. Putting the MacroType declaration inside a header fixed the problem.

« Last Edit: Aug 8th, 2017 at 3:24pm by ikt »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12186
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Strange Visual Micro compile errors while Arduino IDE compiles normally?
Reply #3 - Aug 8th, 2017 at 4:29pm
Print Post  
I see. Yes until fairly recently Arduino did the same. There will be an update in the not too distant future. In the meantime work with a .h (and .cpp if needed) file for user types.

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


Posts: 12186
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Strange Visual Micro compile errors while Arduino IDE compiles normally?
Reply #4 - Aug 9th, 2017 at 8:25pm
Print Post  
Sorry forgot to add,  you can also add the prototypes yourself at the correct location with exact same signature as the method.

Arduino are about to switch to a new method so Visual Micro will be updated once that matures.
« Last Edit: Aug 9th, 2017 at 8:26pm by Tim@Visual Micro »  
Back to top
IP Logged
 
ikt
Newbies
*
Offline


Posts: 3
Joined: Aug 8th, 2017
Re: Strange Visual Micro compile errors while Arduino IDE compiles normally?
Reply #5 - Aug 13th, 2017 at 3:47pm
Print Post  
Thanks for that tip Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint