Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C, skip initialisation static array

Tags:

c

gcc

Is there a way to instruct gcc to skip initialization for certain static,volatile variables? I have several circular buffers (declared volatile) that really don't need to be zeroed at startup and on my MCU, it's a waste of about ~2500 tcy.

Thanks in advance,

like image 227
user1973900 Avatar asked Jul 20 '13 09:07

user1973900


1 Answers

If you use gcc, you can place the array object in the .noinit section:

uint8_t arr[1024] __attribute__ ((section (".noinit")));
like image 79
ouah Avatar answered Oct 26 '22 15:10

ouah