Pages: [1]   Go Down
Author Topic: #include paths for libraries  (Read 4200 times)
0 Members and 1 Guest are viewing this topic.
New England
Offline Offline
Jr. Member
**
Karma: 0
Posts: 95
Arduino newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry if this has already been answered elsewhere; I searched and Google'd without success.

The pattern for including a library's header file is
Code:
#include <LibraryName.h>
The Arduino IDE is smart enough to append
Code:
-I/path/to/libs/LibraryName
to the GCC command for every library included.  This works, but doesn't feel natural, and requires doing some fancier footwork when you want to build an Arduino sketch via a Makefile.

Instead, wouldn't it be better to pass
Code:
-iquote/path/to/user/libs -I/path/to/arduino/libs
and then include a library's header file like this?
Code:
#include "LibraryName/LibraryName.h"

It should still be very simple for newbies to grok, but would make the transition to a Makefile simpler.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6783
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Makefile complexity always grows to the point where no one person understands them anymore.  Past that, actually :-(

Your suggestion makes sense given the way that Arduino libraries are currently constructed, but that is a relatively recent structure.  Go back a few versions and it was common for "official" arduino libraries to be off in .../hardware/... and user-installed libraries to be in "unspecified" locations all over the disk.  Including a full path to each include file is maximally flexible, and the verbosity of the resulting gcc command isn't really relevant.
Logged

New England
Offline Offline
Jr. Member
**
Karma: 0
Posts: 95
Arduino newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

True, but complexity can be managed. smiley

Regardless of where the libraries are, the IDE knows about them. Regardless of how many search paths there are, they can always be specified with -I or -iquote and done once, versus having to add -I for every library included in the project.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6783
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
#include "LibraryName/LibraryName.h"
Too complicated for the target audience too.  As is, the complexity is hidden by the IDE.  Tough luck on makefile users, but they're supposed to know what they're doing!
Logged

Pages: [1]   Go Up
Jump to: