Bob Simpson

#define issues

Discussion created by Bob Simpson on Oct 31, 2008
Latest reply on Oct 31, 2008 by Bob Simpson
I've run into the following problem with using calculated defines with the compiler.

These three defined in a bean:
//#define DATA_FLASH_SECTOR_SIZE 256u  
//#define DATA_FLASH_END   8191                  
//#define DATA_FLASH_START 4096

These were my defines:
#define NVRAM_SECTORS_RESERVE    4
#define MAX_SECTORS    ((DATA_FLASH_END +1 - DATA_FLASH_START)/DATA_FLASH_SECTOR_SIZE) - NVRAM_SECTORS_RESERVE
#define BLK_SIZE 16
#define MAX_BLKS  (MAX_SECTORS * (DATA_FLASH_SECTOR_SIZE / BLK_SIZE))

MAX_SECTORS calculated correctly to 12 but MAX_BLKS calculated to some number about 65k when it should be 192.  I've had to enter it's value literally to make it work.

Is there a mistake here or is the compiler not able to handle the sequential number of calculations required to get to the value requested? 

I'm concerned if there is some limitation I need to know about.

Thanks.  Bob

Outcomes