Using generated headers

Hello,

I need to include a bunch of header files that were generated by nunavut, which is part of the UAVCAN project. Those headers require that their base directory is in the compiler's search path. There are many includes similar to this: #include <uavcan/si/unit/duration/Scalar_1_0.h>, which seems to be problematic for Arduino's magical build system.

I tried putting everything into the src directory (sketch/src/uavcan/si/...) but the resolver apparently can't find them there. Adding a -Isrc flag to gcc would be an easy fix, but I found no obvious way to do that.

I want to keep everything inside the sketch directory for source control, which rules out creating an external library. There are over 200 headers, that's why I'm not really inclined to fix all include directives by hand.

Where can I put those files so they end up in the include search path? I'm experienced with C, but I'm new to Arduino. Using 1.8.15 on Linux.

Thanks for your help!

If the includes are in the same directory as the sketch, try to use "" instead of <> for includes.

Unfortunately, the Arduino IDE does not provide for this. There have been some feature requests for it. This one would probably be the most interesting:

(Arduino CLI provides the build system for all the official Arduino development software, so a feature implemented there propagates to all the tools)

Arduino CLI does provide a arduino-cli compile --library <library path> flag you can use to specify additional library folders:

So if you don't mind using a command line tool that would probably help you out.

Another option might be to store the library in the sketch folder, but install it in the standard libraries folder via a symlink.


By the way, are you aware of this project?

Thanks for your reply. I'll try the CLI. The 107 107-Arduino-UAVCAN lib didn't work, for one it doesn't have the types we are generating, it also had some issues with the locking code.

You're welcome. I hope Arduino CLI will provide you with an easy path to your goal!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.