Dani
Dani

Reputation: 99

Add large array to c file without recompiling it

I use header files to store a dataset in float arrays like so:

//header
float MNIST_test_data_label[1000][10] = {{...},...};

I include these headers in my main.c and can use the arrays, but the IDE (CodeBlocks) keeps making these headers when I build. I searched for hours now, trying to find a solution to make large amounts of data in form of arrays available to my project as "resources" without the compiler constantly rebuilding them.

Does anyone know a solution for this kind of problem?

Upvotes: 0

Views: 51

Answers (1)

tstanisl
tstanisl

Reputation: 14157

Add an external declaration to the header. Add the actual definition to a dedicated C file:

// header
extern float MNIST_test_data_label[1000][10];

some C file:

float MNIST_test_data_label[1000][10] = {{...},...};

Note that a file with a single line as above should suffice.

Upvotes: 1

Related Questions