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 Recommended File/Folder Structure for Shared Files (Read 5368 times)
gdood
Newbies
*
Offline


Posts: 2
Joined: Feb 15th, 2014
Recommended File/Folder Structure for Shared Files
Feb 17th, 2014 at 9:52pm
Print Post  
Hi,

I have some shared .ino files that I use between projects and would like to just "include" them from a shared folder - when I tried this, the compiler complained.

After reading through some posts here, I understand you must have all project files in the same folder.  I also read that you can put files in subfolders as long as they are in the same parent/project folder.  However, that approach doesn't seem to work well.

What is your recommended approach to sharing files between projects? I don't really want to have copies of them between the two projects.

Thanks!
gdood
  
Back to top
 
IP Logged
 
Marius
Developer
****
Offline


Posts: 204
Location: Centurion RSA
Joined: Sep 7th, 2011
Re: Recommended File/Folder Structure for Shared Files
Reply #1 - Feb 18th, 2014 at 5:47am
Print Post  
Have you looked at putting your shared files in a library directory. If they are shared, do you use the complete file or is it just functions in the file that are grouped together. What I mean with complete file, is it a set of functions that could be a library.
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Recommended File/Folder Structure for Shared Files
Reply #2 - Feb 18th, 2014 at 1:31pm
Print Post  
Hi gdood,

1)

Marius explains about adding your common code to a library. It is the official Arduino way.

2)

Quote:
I also read that you can put files in subfolders as long as they are in the same parent/project folder.  However, that approach doesn't seem to work well.


Maybe some confusion here. Arduino does not support code in sub folders unless under a the libraries areas.

3)

There are small differences between using libraries and sketch code. If you find libraries do not achieve what you need please continue this post by giving a small example of how auto included (shared) .ino code would be useful to you. It can then be considered as a future enhancement.

Thanks
  
Back to top
IP Logged
 
gdood
Newbies
*
Offline


Posts: 2
Joined: Feb 15th, 2014
Re: Recommended File/Folder Structure for Shared Files
Reply #3 - Feb 18th, 2014 at 6:54pm
Print Post  
Thanks for your response, guys.

Marius wrote on Feb 18th, 2014 at 5:47am:
Have you looked at putting your shared files in a library directory. If they are shared, do you use the complete file or is it just functions in the file that are grouped together. What I mean with complete file, is it a set of functions that could be a library.

This is just a grouping of handy functions that I want to use in multiple projects - not a library (nor do I want it as a library, unless it comes down to requiring that).

Tim@Visual Micro wrote on Feb 18th, 2014 at 1:31pm:
Maybe some confusion here. Arduino does not support code in sub folders unless under the libraries areas.

So just putting my "shared" files in the "libraries" folder does not work - I put #include <file.ino> at the top of my project file which doesn't seem to be recognized.  I am thinking that the Arduino rules must only allow true libraries to be placed there.
« Last Edit: Feb 18th, 2014 at 7:25pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Recommended File/Folder Structure for Shared Files
Reply #4 - Feb 18th, 2014 at 7:19pm
Print Post  
You would have to convert them to .cpp and .h files to create a library.

We can consider a shared source code system. It's easy the difficult part is working out how to avoid support problems and how to show error messages with drill down into source code outside of the project.

Maybe we can look at using short cuts in the solution explorer so the code is known to the project.

You can also explore snippets but they won't give you a single location to change all the code in multiple project

http://www.visualmicro.com/post/2013/06/02/Arduino-Code-Snippets.aspx

« Last Edit: Feb 18th, 2014 at 7:24pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Marius
Developer
****
Offline


Posts: 204
Location: Centurion RSA
Joined: Sep 7th, 2011
Re: Recommended File/Folder Structure for Shared Files
Reply #5 - Feb 18th, 2014 at 7:23pm
Print Post  
Any code in the library directory will be compiled as a separate class and then included at link time
You can still use your common code in a library. Just make a class structure and define all your functions a members of the class. Something like "MyStuff.Function_1()" to use it. You will include the MyStuff library once at the top. This way you just keep adding functions to the library.
« Last Edit: Feb 18th, 2014 at 7:24pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint