Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
VS Editor doesn't resolve include paths correctly for Shared projects (Read 266 times)
Glen H
Newbies
*
Offline



Posts: 4
VS Editor doesn't resolve include paths correctly for Shared projects
Jul 27th, 2019 at 11:05pm
 
I have a solution with an Arduino project and an Arduino shared project (solution attached).  The files are in the following structure:

Main (Arduino Project)
  src
    MainClass.h
    MainClass.cpp
ArduinoShared (Shared Project
  src
    ArduinoShared
      SharedClass.h
      SharedClass.cpp

In MainClass.cpp of the Main project, I include a reference to SharedClass.h of the Shared project.  When the shared project is merged into the Main project, the relative path from MainClass.cpp to SharedClass.h will be "ArduinoShared/SharedClass.h".  However, the VS Editor complains unless I put "src/ArduinoShared/SharedClass.h".  If I comply with what the VS Editor wants, I get a compile time error.  See ScreenShots.rtf in the root of the attachment for the error I receive.

Is there an issue preventing the VS Editor from resolving relative paths to shared projects correctly?
Back to top
 

Test_004.zip (32 KB | 1 )
 
IP Logged
 
Glen H
Newbies
*
Offline



Posts: 4
Re: VS Editor doesn't resolve include paths correctly for Shared projects
Reply #1 - Jul 28th, 2019 at 5:31pm
 
The problem I'm seeing is related to the folder structure of the Arduino project, not the Shared project.

In your samples, all references to the Shared projects appear to be made from the ino file, which I would guess is in the root of the Arduino project.

In my solution, the Arduino project contains a "src" folder with cpp files that have references to the Shared project.
Back to top
 
 
IP Logged
 
Bob Jones
Full Member
***
Offline



Posts: 207
Bellingham, WA
Re: VS Editor doesn't resolve include paths correctly for Shared projects
Reply #2 - Jul 29th, 2019 at 1:08am
 
I have no idea whether the problem you are facing is similar to the one I faced, but let me offer a possibility. I have many files that are local to the sketch (i.e. in the same folder as the .ino) and a whole collection of libraries that are referenced by the .ino  To resolve both the local and remote (library) references, I added the following:

In Properties of .ino file, under "Extra flags" add -I"{sketch_path}"
Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10463
United Kingdom
Re: VS Editor doesn't resolve include paths correctly for Shared projects
Reply #3 - Jul 29th, 2019 at 4:32pm
 
Thanks again for this post. There was a bug in Visual Micro where an option to have shared code project root folders automatically added as compiler include paths.

The latest 1907.28.6 release automatically includes these paths and also has a new menu item called "vMicro>Compiler>Add Include (i) for Shared Projects". The setting defaults to ON, so you should find that both intellisense and build will work if you use #include <src/MyCodeFolder/MyCode.h>

https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES


The option did used to exist when shared projects were first released but appears to have got lost in the many changes of the past year.


note: You should already be able to reference code from shared project to arduino because the option that Bob mentions became standard in visual micro some time ago (thanks for the reminder Bob). The project folder is always added as a compiler -I include unless "vMicro>Compiler>Add Include (-I) for Project" is switched off (defaults to ON)
Back to top
« Last Edit: Jul 29th, 2019 at 4:36pm by Visual Micro »  
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print