Author Topic: Evaluating nested arithmetic C defines  (Read 4351 times)

Gary

  • Community Member
  • Posts: 43
  • Hero Points: 5
Evaluating nested arithmetic C defines
« 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.



Have fun,
Gary
« Last Edit: May 02, 2008, 11:27:34 am by Gary »