Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11781

How to treat two or more arrays at separate addresses as one in modern C++?

$
0
0

I am working with a microcontroller and I can only statically allocate an array up to a certain size at a fixed address in flash ram. If the required size exceeds the maximum size, I'll also need to allocate a second array sized to the difference at another fixed address.

unsigned char buffer[BUFF_MAX];  // allocated on free SRAM at 0x1000#ifdef CONF_BUFF_SIZE > BUFF_MAX       unsigned char buffer2[BUFF_MAX-CONF_BUFF_SIZE]; // allocated on 0xF000#endif// lots of yuck and muck with indexing and switching addresses

I would like to convert the code over to modern C++ (c++2x). I would also like to iterate and index over the two buffers as if it were one contiguous array without explicitly calculating the index and switching arrays. How do I achieve this in idiomatic modern C++?

buffer[1000] = 0xFE; // modifying memory in "buffer2"


Viewing all articles
Browse latest Browse all 11781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>