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 Adding files to a project via Solution Explorer vs 'local files override...' (Read 1422 times)
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Adding files to a project via Solution Explorer vs 'local files override...'
Feb 4th, 2019 at 4:26am
Print Post  
I've been in 'header file hell' for the last week trying to figure out why previously working Arduino projects would no longer compile/link in VS/VM, but would compile/link in the Arduino IDE.  It turns out that my effort to troubleshoot another linking problem by moving the relevant header/cpp files into the local project folder backfired on me in VS/VM, but worked fine in the Arduino IDE.

In the Arduino IDE, the compiler/linker always searches the 'sketchbook' folder for required header/cpp files before searching Arduinio\Libraries, so moving these files into the project folder had the desired effect (in the Arduino IDE).  However, in VS/VM these same files were ignored entirely until they were 'added' to the project via the Solution Explorer (right click on the 'Header Files'/'Source Files' folder icon, select 'Add Existing', select the relevant files, and click OK).  Apparently, this action is required WHETHER OR NOT THE 'Local files override library files' VM compiler option is checked.

IMHO, this is a bug in Visual Micro.  If the 'local files override library files' option is enabled, it shouldn't matter whether or not the files are added to the project in Solution Explorer; if they are in the local folder, they will be 'seen'.  If files MUST be added to the project via Solution Explorer to be 'seen', then why have the 'local files override...' option at all?  Shouldn't the compiler always process files that are added to projects via the Solution Explorer, as happens by default with the Arduino IDE?

Just my $0.02

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Adding files to a project via Solution Explorer vs 'local files override...'
Reply #1 - Feb 5th, 2019 at 5:49pm
Print Post  
It's a difficult discussion. Most programmers would want to exclude a file from the build by removing it from the solution explorer, some users would be very confused to see a file compile that is not included in the solution explorer. This is how normal programming works.

Then there is arduino that will only compile ALL files in the project folder.

In visual micro the default is to compile all files in the project folder but this is an option in tools>options>vmicro. The default is on but in the future the default might be off because it's very confusing for people who know VS.

The arduino ide can not see files from other folders (linked sources) so VM does need to look at the solution to work out what should be compiled.

There isn't a right answer except to say that if you assume that anything you want compiled is in the solution explorer then you are in a good place for the future and your project can be more easily known and understood.

In the future I suspect it would be better to entirely dump the concept of compiling files that are not in the solution explorer because it is utterly confusing. However some Arduino users who don;t understand normal IDE's with solution/project explorer might become confused.

VS2017 also released ability to work with Folders instead of projects. This seems closer to how arduino works so might be supported in the future as an alternative way to manage source code without projects.

It's a changing world and VM just tries to glue the different practises together in some way.

Plus the override option is new, the default when not set might change now that it has been tested and proven not to cause chaos.

« Last Edit: Feb 5th, 2019 at 5:50pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Adding files to a project via Solution Explorer vs 'local files override...'
Reply #2 - Feb 13th, 2019 at 2:39am
Print Post  
Tim@Visual Micro wrote on Feb 5th, 2019 at 5:49pm:
It's a difficult discussion. Most programmers would want to exclude a file from the build by removing it from the solution explorer, some users would be very confused to see a file compile that is not included in the solution explorer. This is how normal programming works.

Agreed.  I came to the Arduino world from C/C++/C# and have been using Visual Studio since it first came out.

Then there is arduino that will only compile ALL files in the project folder.

In visual micro the default is to compile all files in the project folder but this is an option in tools>options>vmicro. The default is on but in the future the default might be off because it's very confusing for people who know VS.

This doesn't seem to be the case in my setup.  VM won't compile anything unless it's in the VS Project 'sources' or 'headers' folders.  I see the option ('Compile All Project Folder Sources')  you are referring to in tools->Options->Vmicro. but it is set to TRUE and VM still refused to compile files in the project folder unless they were also listed in the Project's 'Sources' or 'Headers' folders.  I  see that the 'Compile Files In Project' option is set to TRUE as well (says the default is FALSE), so this might explain what I'm seeing. Seems strange that you have both options available, when they seem to be mutually exclusive. In this case, with both set to TRUE, it appears that the 'Compile Files in Project' option takes precedence.  


The arduino ide can not see files from other folders (linked sources) so VM does need to look at the solution to work out what should be compiled.

There isn't a right answer except to say that if you assume that anything you want compiled is in the solution explorer then you are in a good place for the future and your project can be more easily known and understood.

In the future I suspect it would be better to entirely dump the concept of compiling files that are not in the solution explorer because it is utterly confusing. However some Arduino users who don;t understand normal IDE's with solution/project explorer might become confused.

VS2017 also released ability to work with Folders instead of projects. This seems closer to how arduino works so might be supported in the future as an alternative way to manage source code without projects.

It's a changing world and VM just tries to glue the different practises together in some way.

Plus the override option is new, the default when not set might change now that it has been tested and proven not to cause chaos.

Well, I would argue that the 'proven not to cause chaos' may be a little premature.  In my case at least, the combination of the two options in Tools>Options>VMicro and the 'Local Files Override Library Files' certainly caused at least a little bit of 'chaos' for me! Wink.



So there are (I think) three different settings that might effect what files are or are not compiled - two in Tools>Options>Visual Micro, and one in vMicro>Compiler. This suggests there are 8 different combinations  - is there a matrix anywhere that describes what the different combinations do?

BTW, as another small buglet; when I moused over the explanations for the two options in Tools>Options>Vmicro to see the full text, the result was a popup that ran off both sides of my 24" 1920 x 1200 monitor, making it impossible to read the entire message.  As a former help file author myself, I know these flyover windows are a godsend normally, but trying to cram too much text into them defeats the purpose.

Regards,

Frank

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