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 VS Editor doesn't resolve include paths correctly for Shared projects (Read 1339 times)
Glen H
Newbies
*
Offline


Posts: 4
Joined: Jul 18th, 2019
VS Editor doesn't resolve include paths correctly for Shared projects
Jul 27th, 2019 at 10:05pm
Print Post  
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?
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Glen H
Newbies
*
Offline


Posts: 4
Joined: Jul 18th, 2019
Re: VS Editor doesn't resolve include paths correctly for Shared projects
Reply #1 - Jul 28th, 2019 at 4:31pm
Print Post  
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: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: VS Editor doesn't resolve include paths correctly for Shared projects
Reply #2 - Jul 29th, 2019 at 12:08am
Print Post  
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
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VS Editor doesn't resolve include paths correctly for Shared projects
Reply #3 - Jul 29th, 2019 at 3:32pm
Print Post  
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)
« Last Edit: Jul 29th, 2019 at 3:36pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint