Defining a large array larger than the unsigned int limit

I need to define an array statically (in a * .h file) of size 12884901888.

unsigned char sram[12884901888]; //All of my code is C.

The above declaration gives an error and does not work.

Because the constants used in array declarations are unsigned int. But the constant I should use (12884901888) is more than the unsigned int prefix.

How can I define an array as indicated above with a size of 12884901888?

Thanks.

-AD

PS I know that many will say optimize this size of a huge array, but I need to use it for some reason specific to my case.

+3
source share
3 answers

Make the array size unsigned.

unsigned char sram[12884901888ULL];
+2

? - :

#define sram (*((unsigned char (*)[1]) 0))

, . , 12884901888 , .

+2

12884901888 : 0x3-0000-0000 ( 16 )

, 3 4 Gig , 34-

finnw, . , OBJ ELF/EXE .

0

Source: https://habr.com/ru/post/1710550/


All Articles