VS Arduino
>> >> VS Editor doesn't resolve include paths correctly for Shared projects
https://www.visualmicro.com/forums/YaBB.pl?num=1564265113

Message started by Glen H on Jul 27th, 2019 at 10:05pm

Title: VS Editor doesn't resolve include paths correctly for Shared projects
Post by Glen H on Jul 27th, 2019 at 10: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?

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=Test_004.zip ( 32 KB | 0 Downloads )

Title: Re: VS Editor doesn't resolve include paths correctly for Shared projects
Post by Glen H on Jul 28th, 2019 at 4: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.

Title: Re: VS Editor doesn't resolve include paths correctly for Shared projects
Post by Bob Jones on Jul 29th, 2019 at 12: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}"

Title: Re: VS Editor doesn't resolve include paths correctly for Shared projects
Post by Visual Micro on Jul 29th, 2019 at 3: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)

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.