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 Adding a custom Library adds includes for all sub header files included in that library. (Read 205 times)
McCoderGuy
Newbies
*
Offline


Posts: 3
Joined: Mar 1st, 2024
Adding a custom Library adds includes for all sub header files included in that library.
Nov 12th, 2024 at 7:39am
Print Post  
Hey Guys,

I'm doing a lot of library development for my projects, and have created a number of my own custom libraries for things. With most of my libraries, I organize them using multiple headers and .cpp files (all in /src) for the different classes and components of the library and then I #include them in that main Library file. So far, this all works great for me and I have fairly nicely organized Libraries.

Thing is, and it's only a slight annoyance: when I add that library to a new Arduino project, using the VM menu, it will automatically #includes every header in the Library's /src folder, to my .ino file.

Usually, I just delete all the extraneous #includes, leaving behind only the Libraries main .h file, and it always works without issue. Everything I need is available to me in the .ino and it all works with Intellisense just fine. It hasn't actually been a compiler or linker problem, so I've just been dealing with it this way for awhile now.

However, libraries other than mine, do not do this. I've looked at the source with these other libraries before, and there are some that have extra headers like mine (can't remember which at the moment), but I could never figure out what they were doing differently from me so that their extra headers wouldn't be auto included like this.

Also, I'm not sure if this is just a VM thing, or if it's an Arduino thing, since I haven't really ever used the Arduino compiler, I sort of just went straight to VS and VM when I first started with all this microcontroller madness, and I haven't been able to figure out what my search on Google would even be for this. 

Cheers and Thanks for any insights or help you can offer.
« Last Edit: Nov 12th, 2024 at 7:56am by McCoderGuy »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2499
Joined: Feb 13th, 2019
Re: Adding a custom Library adds includes for all sub header files included in that library.
Reply #1 - Nov 12th, 2024 at 7:47am
Print Post  
In your library.properties file, have you set the "includes" property?

If this is omitted all headers are added to the sketch, and if specified only those are added.

This is the same in the Arduino IDE and can be found in the Arduino CLI Specification on the below page:
https://arduino.github.io/arduino-cli/0.19/library-specification/#librarypropert...
  
Back to top
IP Logged
 
McCoderGuy
Newbies
*
Offline


Posts: 3
Joined: Mar 1st, 2024
Re: Adding a custom Library adds includes for all sub header files included in that library.
Reply #2 - Nov 12th, 2024 at 8:09am
Print Post  
Simon@Visual Micro wrote on Nov 12th, 2024 at 7:47am:
In your library.properties file, have you set the "includes" property?

If this is omitted all headers are added to the sketch, and if specified only those are added.

This is the same in the Arduino IDE and can be found in the Arduino CLI Specification on the below page:
https://arduino.github.io/arduino-cli/0.19/library-specification/#librarypropert...


Honestly, this is exactly why I love VM and this forum! I've been lurking for awhile now, and usually don't land up posting, because you guys provide such great answers that usually answer my today question anyways, and plus, you do it so quick!

Anyways, the last few years I've done so much learning (C/C++, OOP, MCU/Arduino, ElecEng), and this is an area I've really been needing to deep dive into, but I kind of forgot about it trying to learn everything else and solve all my other problems (templates, for example, took forever to finally "get"). 

Thanks for giving me this handle into it... This looks like exactly where I needed to start, so I think I'll top up the coffee and set in for a few hours of reading and learning...

Cheers,

Rob
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint