I regularly want to include (compile in) binary data from external files as an uint8_t
array into my programs (embedded or bare metal).
Is there a way without the extra step of converting them into a hex arrays? Because this involves extra build steps that sometimes are not that easy to integrate e.g. in case of Arduino tool chain. And doing this manually always results in forgotten hex-updates :-)
Normally I am using gcc. So I also would be happy if it is a gcc-specific pragma or another extension (although not that happy as with an generic solution).
maybe something like
static const __attribute__((rawDataFromFile("myDataFile.bin"))) uint8_t s_data[];
instead of the classical way to external
bin2hex myDataFile.bin myDataFile.hex
and
static const uint8_t s_data[] = {
#include "myDataFile.hex"
};
Solutions that work in C
and in C++
would be preferred, but suggestions that only work in one of the two are also welcome.