I'm new to c++ programming and use it to program a microcontroller. Since memory is limitted (only 12 kb), I'm looking for a way to reduce memory usage when using some large arrays with floats that are constants. Is it possible to somehow write these arrays to ROM without them having to be transferred to memory before usage?

I did try something like:

static const float myArray[100] = {1.23, 4.56, .... }

, but this does not seem to be working.

It's not C++ language question. It's a question about YOUR compiler and linker. Read the compiler reference guide carefully, look at module map, try and see what happens - and so on...

And if you're still stuck after reading, then tell us which compiler you're using.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.