Is it possible to increase the maximum size of an array ?

Hello,

Suppose I want to store a big big array, in progmem. I will be limited by the maximum size of an array, that is, 32767 bytes.

From what I understand, the maximum size of an array is defined by the maximum value that size_t can hold. So this would mean that size_t was defined as a signed int. But by looking into stddef.h I see:

#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
#endif
#if !(defined (__GNUG__) && defined (size_t))
typedef __SIZE_TYPE__ size_t;

I'm not sure to understand exactly, but doesn't this mean size_t was defined as an unsigned long ? And if so, why am I unable to make arrays larger than 32767 bytes?

My main question is of course: is it possible to increase the maximum size of an array (and how) ?

Thanks :slight_smile:

No you are also limited by the pointer size, which is 16 bits on ATmega AVR's

guix:
My main question is of course: is it possible to increase the maximum size of an array (and how) ?

No, the limit for 8-bit Arduinos is 32767 for a single array, and 64 kB for PROGMEM all together.

If you need less than 64 kB in PROGMEM, you possibly could use 2 arrays.

If you need more than 64 kB of data in flash memory, you will have to write your own flash memory access routines and cannot even use PROGMEM.