Pages: [1]   Go Down
Author Topic: Conflicting library files  (Read 295 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm writing libraries and having the library folder structure like this:

libraries
  -Foo
    -Foo.h
    -Helper.h
  -Bar
    -Bar.h
    -Helper.h
  -Helper
    -Helper.h

I figured that if I write "#include <Helper.h>" in my sketch, it'll be impossible to control which "Helper.h" is included.
"Helper.h" is included in other libraries, mostly for the concern that it's easier for end user to get the library running, and I have better control over its configurations(Some libraries need to have their source code modified to be configured).

So is there a way to hide the "Helper.h" in Foo and Bar, so if I write "#include <Helper.h>", only the one from Helper folder will be included?
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 84
Posts: 3422
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can rename them, just make sure you change them in .cpp files too.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just figured out a way that seemingly solves the problem:


    libraries  
      +Foo
        -Foo.h
        +extra
          -Helper.h  
      +Bar
        -Bar.h
        +extra
          -Helper.h  
      +Helper
        -Helper.h


In this way, `Helper.h` in `Foo` and `Bar` would be invisible to sketches, and I can write `#include "extra/Helper.h"` in `Foo` and `Bar` respectively to include the desired files.

With more tests, it turned out that this method does not solve the problem, but hiding it a lever deeper. So if you include Foo and Helper, Bar and Helper, or Foo and Bar, only one version of Helper.h will be included.
« Last Edit: May 02, 2013, 01:05:00 pm by X_Y » Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 84
Posts: 3422
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is one way to do it. Not the proper way, but it is a way.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Pages: [1]   Go Up
Jump to: