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 Code won't compile and compiler warnings are pretty useless (Read 4553 times)
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Code won't compile and compiler warnings are pretty useless
Jan 8th, 2016 at 8:19pm
Print Post  
My code uses several libraries, most of which I created as part of this sketch. They all reside in the /src/_micro-api/libraries folder. 
My sketch code (Rover.ino) uses #defines and #if compiler directives to decide which libraries to include. It compiles with only one error and a bunch of warnings. Unfortunately, even with warnings and verbose mode enabled, the warnings only name a function that has a problem but say nothing about what the problem is, so I am at a loss about how to fix these problems.

I recognize that this is a compiler issue, but I am hoping that somebody has a good enough understanding of what the problems are that I can fix them.

I have attached the entire project as Rover.zip. The entire compiler output is in the file /rover/Output.txt.
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Code won't compile and compiler warnings are pretty useless
Reply #1 - Jan 9th, 2016 at 4:54pm
Print Post  
Which versions of Visual Studio, Arduino and Visual Micro are you using?

When I compile I get a clear error in the output

Code
Select All
Compiling 'Rover' for 'Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)'
IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope
:int RECV_PIN = TKD2; \\ the pin the IR receiver is connected to
Error compiling libraries 



The reason for the error is that you are trying to use a #define from the sketch in library code. Arduino doesn't work that way the libraries have no knowledge of the local sketch code.

To set defines globally you can use the Visual Micro "Micro General>Defines". It's a semi-colon sep list. There are two "defines" properties, one is global for project the other is specific to configuration specific (release/debug/custom etc.)

Code
Select All
ENABLE_BJCOMMANDER=false;ENABLE_BJDETECTOR=true 



Info: How to use Arduino to test local libraries?

The local project libraries "[project_name]\src\_micro-api\libraries" are compiled in the same way as normal Arduino libraries. This means that you can copy the libraries to your "arduino user library" folder which is normally "documents\Arduino\libraries"

If libraries exist in both locations then Visual Micro will use the local project version (if it exists) which allows new library code to be developed without breaking other working projects. Other Visual Studio projects that use the libraries (or the Arduino ide) will use the "Published" version under the "documents" folder.

BUT we aware that the Arduino Ide does not have the facility to add extra defines to the project builder in the same that you can in Visual Micro (other than editing the build definitions and adding custom board entries such as "Rover Type 1" etc.). This can be done in boards.txt but only applies if you have a few main "groups/classifications" of #defines
« Last Edit: Jan 9th, 2016 at 5:52pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Code won't compile and compiler warnings are pretty useless
Reply #2 - Jan 9th, 2016 at 7:49pm
Print Post  
Thanks. It feels like progress, but I am still missing something. I am using VS 2013 and I think I am using the PRO version of VM, but I cannot find the windows referred to in the Project Properties documentation on the VM website. 

I have enclosed screen shots of my environment in the attached ZIP file, but the bottom line is that I cannot find the "Defines - Project" panel. 

Do I need to upgrade to VS 2015? Am I using the wrong version of VM? Or am I just looking at the wrong screens?
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Code won't compile and compiler warnings are pretty useless
Reply #3 - Jan 9th, 2016 at 8:16pm
Print Post  
Please see "project Properties" in the Visual Micro documentation http://www.visualmicro.com/page/User-Guide.aspx?doc=index

Or see the "project Properties" menu item on the "Visual Micro" menu.

A dockable tool window will appear with the properties
« Last Edit: Jan 9th, 2016 at 8:17pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Code won't compile and compiler warnings are pretty useless
Reply #4 - Jan 10th, 2016 at 7:02am
Print Post  
Making progress now that I have upgraded to VS 2015; however, I wonder: is there any reason why I can't / should not put these defines into a header (.h) file and include that in the sketch? Will that work?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Code won't compile and compiler warnings are pretty useless
Reply #5 - Jan 10th, 2016 at 4:35pm
Print Post  
There you can use header files in the sketch but they still won't affect libraries or core. 

Are you sure you need to use libraries?  Can't you put your code in sub folders of the sketch and #include as normal with "path\header.h"?

Alternatively maybe creating custom board defs is better for you. If you take a look at Teensy or Esp8266 boards when installed in Visual Micro you can see they provide the ability to switch on or off groups of options for each board. Each option can add a define to the global compile. You should try to limit options to no more than 5, there is a limit at the moment, I think it's 15



The quickest when testing is the project properties and you will see there are some also per configuration. That you can also easily create your own configuration names instead of just "Release" and "Debug".
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint