Tim@Visual Micro wrote on Oct 23
rd, 2018 at 8:08pm:
How do the macros you mention relate to arduino?
I thought this was clear enough, but perhaps you'll have to pass this on to your developers for a more thorough understanding of the topics discussed.
Here is an excerpt from the AdditionalIncludeDirectories settings from my Visual Micro project file, AS CREATED BY VISUAL MICRO.
(In this specific case, this file is located at "D:\Projects\mSlider\mSlider\mSlider.vcxproj" on my desktop computer.)
<AdditionalIncludeDirectories>
$(ProjectDir)..\mSlider;
C:\Program Files (x86)\Arduino\libraries;
C:\Users\Scott Ferguson\OneDrive\Documents\Arduino\libraries;
</AdditionalIncludeDirectories>
Here are the relevant macros and their definitions:
$(ProjectDir) ==> D:\Projects\mSlider\mSlider\
$(ProgramFiles) ==> C:\Program Files (x86)
$(USERPROFILE) ==> C:\Users\Scott Ferguson
You're already using the $(ProjectDir) macro in the first case. This is GOOD.
In the second and third cases you are referencing machine-specific and user-specific drives and directories. This is BAD.
This causes problems for source code control systems, such as Git, because each project team member or machine
will almost certainly have to have a DIFFERENT version of the file, causing constant merge conflicts.
When better, more transportable options are readily available, this should be considered a BUG!
Here is what those project settings paths SHOULD look like using the proper macros:
<AdditionalIncludeDirectories>
$(ProjectDir)..\mSlider;
$(ProgramFiles)\Arduino\libraries;
$(USERPROFILE)\OneDrive\Documents\Arduino\libraries;
</AdditionalIncludeDirectories>
These settings are machine-independent and user-independent and are therefore transportable. This is GOOD.
To highlight an additional problem (BUG) in Visual Micro, here is the same project file excerpt after
loading and use on my laptop computer where it is located at "C:\Projects\mSlider\mSlider\mSlider.vcxproj".
<AdditionalIncludeDirectories>
$(ProjectDir)..\mSlider;
$(ProjectDir)..\..\..\Users\Scott\OneDrive\Documents\Arduino\libraries;
$(ProjectDir)..\..\..\Program Files (x86)\Arduino\libraries;
</AdditionalIncludeDirectories>
Because the second two cases have paths on the same drive as the Project file, Visual Micro attempts
to use the $(ProjectDir) macro where it does NOT apply, creating a relative path that goes all the
way to the root of the C: drive and back up to find libraries in the "Users" directory and the "Program Files (x86)" files
directory. This is BAD. These problems would all be resolved through proper use of the above macros.
The project file would not need to change and create merge conflicts in source code control for every user and every
system it appears on.
This is the way Visual Studio itself saves settings in a machine-independent and user-independent way.
These macros are present on ALL systems and therefore can be used without having to create, modify or set any macros.