Go Down

Topic: Conflicting library files (Read 355 times) previous topic - next topic

X_Y

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?

HazardsMind

You can rename them, just make sure you change them in .cpp files too.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

X_Y

#2
May 02, 2013, 06:52 pm Last Edit: May 02, 2013, 08:05 pm by X_Y Reason: 1
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.

HazardsMind

That is one way to do it. Not the proper way, but it is a way.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Go Up