Included Data(fonts bitmaps etc) in a library , best practice?

Hi

Whats the best practice or optimum way to include large read-only data arrays like fonts and bitmaps data in a C++ embedded library, Assuming you want to have the data in separate files.

Lets imagine the following structure

  1. test.ino
  2. lcd.h , lcd.cpp
  3. graphics.h graphic.cpp
  4. font_data.h font_data.cpp
  5. bitmap_data.h bitmap_data.cpp

3 is included into 2 and 2 is included into 1.
4 is only used in 3 and 5 is only used in 1.

Is it Ok to just have the data arrays in the .h file?

regards

Usually I put fonts and bitmaps in .h files, corresponding .cpp files are not used and not created.

what is in this file?

In most of my C++ projects , nothing.

Header files pre-date C++. It's perfectly normal to put large data declarations in a .h file. It's standard procedure. No other files to support them are needed or appropriate.

If there is nothing there, why is it needed?

When it's not empty, what's in it?

I also code in C embedded (stm32, pic etc) , In C projects I am putting the Data arrays there in the .c file and sharing it with the other file that needs it with "extern" and pointers. So in C the .h file
was no data in it. See post 6 at link.

I just included the cpp files even though they are empty.
I am trying to figure out whats best practice in C++ and if I am doing something wrong.

the best practice is the one you know

I think you might be combining C and C++ approaches in some way that conflicts. They are not the same language.

But I have coded in both, and something like a font file has always been a .h file, for me.