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 Include Path (Read 10994 times)
nickclark76
Newbies
*
Offline


Posts: 4
Joined: Sep 13th, 2012
Include Path
Sep 19th, 2012 at 12:55pm
Print Post  
Is it possible to add a new include path to a project, for including your own header files?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include Path
Reply #1 - Sep 19th, 2012 at 2:11pm
Print Post  
Hello,

At the moment, unless I hear otherwise, it is strictly arduino compatible.

This means that the sketch is copied to a temp folder, the .ino and/or .pde files are combined into a .cpp and then compiled. 

So relative include paths are not possible, I have never tried referencing #includes using a fully qualified path and I am not sure it would work.

What you can do

You can add your own #includes to .h files that exist in the same folder as the sketch. The same folder can also contain .c and/or .cpp files.

To see an example of how these local includes work you can right click the project in the solution explorer and use the "Add>New Cpp Item". This will create new .h/.cpp (class) files and add an #include to the top of the [master_sketch].ino file.

ReCap: Cpp and h files work as normal except that they must reside in the same folder as the sketch


One way to reference includes from other locations is to turn them into arduino libraries. This is easy to do by creating a new "[My Documents\Arduino]\Libraries\MyLibBlah" and adding at least one .h file with the same name as the folder (MyLibBlah.h). nb: "My Documents\Arduino" must be the name of your arduino preferences "sketch folder".

Once you have created the library either re-start visual studio or click on the project node in the Solution Explorer and from the top menu click "PROJECT>Add Arduino Library>Refresh"

The new library will appear on the "PROJECT>Add Arduino Library>User" menu, clicking it will insert #includes for all .h files in your library. 

If you add more .h files to your library then you will need to make sure you add #includes into the [mysketch.ino] file.

When working with your own libraries a useful feature is "PROJECT>Show all arduino files". This will add your library source codes directly into the Visual Studio solution explorer allowing you to edit both the sketch and the library sources at the same time, prior to upload.

I hope this helps, if this doesn't answer your question please speak up Smiley

Thanks

ps: a good idea for our codeplex issues list might be to allow you to add your own global .h files to the vs C++ include paths list? If you need this then please register it on the vidualmicro.codeplex.com issues list
« Last Edit: Sep 19th, 2012 at 2:13pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
nickclark76
Newbies
*
Offline


Posts: 4
Joined: Sep 13th, 2012
Re: Include Path
Reply #2 - Sep 19th, 2012 at 3:02pm
Print Post  
Thank you for your reply.

Yes it does answer my question, althought its not necessarily the answer I was hoping for.  Embarrassed
  
Back to top
 
IP Logged
 
Arnold
Junior Member
**
Offline


Posts: 17
Joined: Feb 6th, 2018
Re: Include Path
Reply #3 - Feb 19th, 2020 at 7:11pm
Print Post  
How long we still have to wait for this. 
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include Path
Reply #4 - Feb 19th, 2020 at 9:59pm
Print Post  
It's been possible for many years to add -I compile include paths. Click the project name in the solution explore then press F4 to see the project properties. Add your includes to the extra flags in the compile section:-

Code
Select All
-I"c:\mypath\includes\a" -I"c:\mypath\includes\b"  




You can also make use of shared code projects and shared library projects. These allow for an unlimited amount of code in any folder(s) but will all conform to the arduino standard. That way all the code can be shared with the Arduino community and more easily supported in the many different forums for Arduino.
« Last Edit: Feb 20th, 2020 at 12:25am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint