SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: Gary on May 01, 2008, 10:27:10 AM

Title: Evaluating nested arithmetic C defines
Post by: Gary on May 01, 2008, 10:27:10 AM
Hi all,

since I had to deal with rather complex arithmetics hidden in nested defines I have written a wee macro which I would like to share with you.

The #defines I had to deal with look like this:

Code: [Select]
#define AVAILABLE_ROM_SIZE (200 * 1024)
#define MODULE_A_ROM_SIZE  0x200
#define MODULE_B_ROM_SIZE  1234

#define MODULES_ROM_SIZE (MODULE_A_ROM_SIZE + MODULE_B_ROM_SIZE)


#define REMAINING_ROM (AVAILABLE_ROM_SIZE - MODULES_ROM_SIZE)

I have bound the function Eval_C_Define which is part of the attached file 'cmacrotools.e' to key [Ctrl]+[?]. If you place the cusor on such a define and press [Ctrl]+[?] you get a message box showing the result value.

(http://Eval_C_Define.bmp)

Have fun,
Gary