Const data optimisation for Arduino I'm taking a course on Arduino Uno programming and on today's talk I heard that the const data is optimized by Arduino, so that it occupies less space than the actual data type (namely, a const int occupies less than an int).

If instead of int I use const uint8_t, const uint16_t etc. is the optimization still applied, or does using the 8 and 16 bit ints represent bad practice?
This question is not really about the Arduino. It is about GNU C/C++ compiler optimizations. 

By adding the keyword const the compiler can do a lot of optimization. One is that the value does not need to be stored in SRAM. The value can end up as part of an instruction, become part of an expression that is evaluated at compile-time, etc. 

In the Arduino-GPIO library static const member data is used to allow the compiler to optimize to a single instruction digitalRead() with almost X100 performance improvement (on Arduino Mega). 

Check GCC and AVR optimizations for further details. 


http://www.nongnu.org/avr-libc/user-manual/using_tools.html
https://gcc.gnu.org/wiki/avr-gcc
http://www.linuxjournal.com/article/7269


Cheers!