Is there a preprocessor constant for memory size
Find the io__.h file for your microcontroller, on Linux it is located in /usr/lib/avr/include/avr, on Windows it will be in a somewhat similar location.

Scroll down to the part that says /* Constants */. There are couple interesting macros defined there, FLASHEND being the one you should be interested in. You can use it for example as follows:

#if FLASHEND &gt; 0x8000
/* Include some extra code when sufficient flash is available. */

#endif