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 not declared in this scope (Read 5576 times)
Pedro Albuquerque
Newbies
*
Offline


Posts: 2
Joined: Jun 1st, 2016
not declared in this scope
Jun 1st, 2016 at 9:46am
Print Post  
I'm new to visual studio and visual micro.

I've been using arduino ide to do my development, and decided to try visual Studio/visual micro solution.

my sketch is compiling and running with arduino IDE just fine yet when using visual micro I get and error

"Sketch2.ino:In function 'void setup()
Sketch2.ino:279:22: error: 'displaymenu' was not declared in this scope
:displaymenu(menuPage)
Sketch2.ino:In function 'void loop()
Sketch2.ino:295:13: error: 'changeMenu' was not declared in this scope
:changeMenu()
Sketch2.ino:296:22: error: 'displaymenu' was not declared in this scope
:displaymenu(menuPage)
Error compiling project sources
"

To turn arround the problem I had to declare all function prior to setup() and loop() declaration by adding this code 

"int len(char* str);
byte checksum(char *str);
void changeMenu();
void d2i(float input, float factor, long &major, long &minor);
long min2dec(long minor);
float GPSDist(float uselat, float uselon, long int *homedist, long int *homeazim);
void displayReset();
void fixposition();
void logposition(float loglat, float loglong);
void displaymenu(byte menuPage);
"
the function definition code is still placed after setup() and loop() definition.

1- WHY ? 
2- is there an option to allow code syntax to respect arduino  IDE rules ?

thank you for any help you may give.
« Last Edit: Jun 1st, 2016 at 9:47am by Pedro Albuquerque »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12136
Location: United Kingdom
Joined: Apr 10th, 2010
Re: not declared in this scope
Reply #1 - Jun 1st, 2016 at 11:32am
Print Post  
Hi,

It is a relatively new feature of the Arduino Ide to determine the best location to insert the auto generated prototypes. In fact the new facility only matured and became rock solid in the latest Arduino 1.6.9.

Previously Arduino worked how Visual Micro still works, whereby any methods, in the .ino, that use types also declared in the .ino (and not in a .h) must have manually inserted prototypes at a location after the "user type or struct" has been defined.

In your example I don't see any user defined types however the same system also avoids an issue if you have a #if as the first code statement the prototype will end up inside the #if condition.

You can always see the real code that gets compiled by switching on "tools>options>vm>compiler>show build folder" which gives you a link in the compiler output to the temp build folder. Then look at the project_name.cpp.

You did well to see the solution yourself. This will be implemented within the next month.
  
Back to top
IP Logged
 
Pedro Albuquerque
Newbies
*
Offline


Posts: 2
Joined: Jun 1st, 2016
Re: not declared in this scope
Reply #2 - Jun 1st, 2016 at 12:00pm
Print Post  
Thanks Visual Micro for your timely comment.

I am actually using IDE 1.6.9 , and I do have a user defined type (a struct).

Just by pure change I did insert my definition after the user defined type and it worked (I was not aware of such requirement).

thank you for your confirmation and i'll be waiting for that new feature Wink.

Is there a version of visual micro to run on a MAC on top of some MAC(ish) IDE, like Xcode, or atom, or QT or ????
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12136
Location: United Kingdom
Joined: Apr 10th, 2010
Re: not declared in this scope
Reply #3 - Jun 1st, 2016 at 12:04pm
Print Post  
Ok thanks.

No at the moment I think Visual micro only works on Mac using a windows virtual machine and visual studio.

Microsoft are very interested in the Arduino community so I expect they will produce a solution for the new VsCode editor which works on linux, mac and windows.

If they don't do that I might look at it over the next year.

ps: sounds like you only needed the one manually entered prototype
« Last Edit: Jun 1st, 2016 at 12:05pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint