-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add sketch subdir in the Include Path #3080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you also code and put on gist a short example sketch that we can use to test the feature? |
see #1152, the sdlib is a perfet example that actually works because a special case in the code |
Seems you might be mixing up things. For "new-style" libraries, source files in subdirectories of the src/ directory are compiled, but AFAIK these subdirectories are not added to the include path. Doing so would actually be counter-productive - it would merge all those directories in a single namespace, greatly increasing the chance of naming conflicts. If you want to include pippo\somedir\x.h from pippo.ino, you can just use |
#include "somedir/x.h" this is exactly the think that do not work, i do not speak about a library problem, but simply including header like your example. This is very usefull on big project. I uploaded a simple sketch+subdir here: |
Could it be a \ vs / issue? I think includes normally use /, even on Windows. Try using a / in your include too and tell use if that helps. |
On Arduino IDE, at least on Windows but i think on linux also, there is no difference: you can do this: or this Togheter always work, try yourself whit my uploaded sketch |
this is the example in the uploaded file: #include "test1.h" // This work
#include "C:\test2.h" // This work
#include "SomeDir\test3.h" // This is the ISSUE request
void setup() {
}
void loop() {
} |
Ah, I understand what happens now - .ino files are preprocessed and the result is written to the temporary build directory. I think any .c / .cpp and .h files are copied to the build dir too, but not subdirectories, so the include does not work (just tested this, breaks for me too). To fix this we could put the original sketch directory (not the subdirectory) in the include path. However, this blurs the distinction between "" and <> includes, so I'm a bit hesitant to propose that. Copying subdirectories into the build dir might make sense, though then I guess also .cpp and .c files in subdirectories should be compiled for consitency (might be a good idea anyway). @ffissore, any thoughts?= |
I vote for copying subdirectories into the build dir together whit any .h .c .cpp inside the subdir |
I think this is related to #2997. The same reasons for fixing #2997 apply here. A safe way for fixing both could be to 1) create three subfolders in the temp dir: "core", "libraries", "sketch" 2) preserve the whole directory structure for each
I wonder if such a structure could make life even harder WRT #1337 |
this new structure can only be a good thing :-) |
@ffissore this is a good starting point, there i see 2 main solution; one is to slowly break compatibility with that system and start inducing user to use relative path (the 3 "entry point" are core/cores/arduino/, libraries, and tmp folder) or keeping the compatibility but using only one gcc command, you can stop coping everything and just copy all the file but the .ino, generate the sketch_may05a.cpp, the ONE gcc command like cd /tmp/build123/ where $include is a list of absolute path to ALL folder into the "libray" plus "core/cores/arduino/" (obviusly depend on the core used). OR you can even skip the copy of the subfolder of the sketch, and add it as the include; the nice thing is that the include orader is the PRIOORITY order, so if multiple .h are present (like in the case you are using the IRlibrary) we don't compilation error; i think the sketck folder should win again all, themn libraries, and then core. |
Now that #2997 is cosed, is it possible close this isdue also ? |
here we go #3435 |
Very good, i will test it. |
Actually is possible include in the sketch an header file only if it is in:
pippo\pippo.ino
pippo\x.h
c:\x.h
Please add the possibilities of use subdir in the sketch:
pippo\somedir\x.h
The text was updated successfully, but these errors were encountered: