You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
Right now, as far as I know, it only understands sketches. If you try to build without a sketch, it will complain to you.
This makes it impossible to develop a library with proper IDE support.
Fine.
So we add "sketch": "examples\\my_example\\my_example.ino" to our arduino.json and reference our library from sketch.
#include <my_header_only_library.hpp>
Because it's considered a System Library, and our project resides in the System Library location, Arduino knows where to find my_header_only_library.hpp. The problem is, because we are including it as a System Library, Intellisense will not work as Intellisense is only generated for non-system libraries (which is a good thing!)
What if instead, we refer to it via a relative path as a header local to this sketch?
#include "../../src/my_header_only_library.hpp"
Arduino does not respect this syntax; it will only respect local paths that are within our sketch's root directory.
However, if we move our library within the sketch's root directory, then we are no longer a library as we are not following the required structure for a library.
So as far as I can see, the only way to develop a Library using VS Code with Intellisense, static analysis, formatting, etc. support is to create a top-level, temporary, sketch that imports your library and you have to delete it once you're done. Because, otherwise, the plugin will not generate a compile_commands.json that references the library source files.
To make matters worse, this scenario does not support header-only libraries as the generated compile_commands.json does not contain a file declaration for header-only libraries which makes it impossible to develop templated libraries, etc.
The text was updated successfully, but these errors were encountered:
Hello,
When developing a library for Arduino as the documentation states, you are to create the following folder structure:
Right now, as far as I know, it only understands sketches. If you try to build without a sketch, it will complain to you.
This makes it impossible to develop a library with proper IDE support.
Fine.
So we add
"sketch": "examples\\my_example\\my_example.ino"
to ourarduino.json
and reference our library from sketch.Because it's considered a System Library, and our project resides in the System Library location, Arduino knows where to find
my_header_only_library.hpp
. The problem is, because we are including it as a System Library, Intellisense will not work as Intellisense is only generated for non-system libraries (which is a good thing!)What if instead, we refer to it via a relative path as a header local to this sketch?
Arduino does not respect this syntax; it will only respect local paths that are within our sketch's root directory.
However, if we move our library within the sketch's root directory, then we are no longer a library as we are not following the required structure for a library.
So as far as I can see, the only way to develop a Library using VS Code with Intellisense, static analysis, formatting, etc. support is to create a top-level, temporary, sketch that imports your library and you have to delete it once you're done. Because, otherwise, the plugin will not generate a
compile_commands.json
that references the library source files.To make matters worse, this scenario does not support header-only libraries as the generated
compile_commands.json
does not contain a file declaration for header-only libraries which makes it impossible to develop templated libraries, etc.The text was updated successfully, but these errors were encountered: