I'm building a small library that will be used and production and released open source. I'm paying a lot of attention to the "best practices" to make sure this code is reliable and easy to use. I also would also like to make this easy to edit. I'm having an issue with the naming scheme of the whole project.
There are a few Arduino naming quirks. If I have a sketch called mylib
:
- ...I can't create a tab called
mylib.cpp
. However, I can create a file calledmylib.h
... - ...The folder and main sketch file must be the same name as the folder it is in
- ...The sketch name (and folder) cannot contain any spaces.
Well, why are you creating a sketch for a library? The Arduino IDE won't open a .cpp
file unless there's a sketch in that folder (and you have to open the .ino
/.pde
file in that folder). I'm trying to get this to work with the Arduino IDE so, if users need to edit the library, then can just open the file and go to the correct tab. If they use an external editor, they won't be able to compile it to see if there are any errors.
I'd ideally just do this structure:
my_lib
|- my_lib.ino
|- mylib.cpp
|- mylib.h
However, a user might see that the folder is called my_lib
and try including the file my_lib.h
.
I think this is a major oversight in the Arduino IDE, but I need to have this work with the Arduino IDE. If it was just me working on this code, I might consider making the library directly in a project directory, but that isn't ideal. Is there anything that I can do to bypass this/make it easy for users to edit? Is there any "standard"/"convention" that defines how to do this?
.cpp
file in the first place to see if it compiles? You can't, and the command line isn't ideal (even if it supports compilation from non.ino
files)