[En-Nut-Discussion] Configuration: Is there something like a "forced" macro?

Harald Kipp harald.kipp at egnite.de
Thu Oct 4 09:34:24 CEST 2012


Hi Uwe,

On 03.10.2012 23:37, Uwe Bonnes wrote:
> I miss a functionality in the configurator: 
> Write out a macro name "XXX" if some requirement is fullfilled,
> even if "XXX" is _not_ defined in the conf file.

I'm not sure, if I understood your requirement. If not, please correct me.

For example, the AT91 family is quite large and in order to avoid long
ifdef lists, additional macros are generated by the Configurator.
Looking to the AT91SAM7X-EK board:

 #define MCU_AT91SAM7X256

is created by

 MCU_AT91SAM7X256 = ""

in the config file. Based on this, the Configurator additionally creates

 #define MCU_AT91 1
 #define MCU_AT91SAM7X 1

because "MCU_AT91SAM7X256" provides the following requirements

 "HW_MCU_AT91",
 "HW_MCU_AT91SAM7X",

which activates

 {
  macro = "MCU_AT91",
  brief = "Atmel AT91",
  type = "integer",
  default = 1,
  requires = { "HW_MCU_AT91" },
  file = "include/cfg/arch.h"
 }

and

 {
  macro = "MCU_AT91SAM7X",
  brief = "Atmel AT91SAM7X",
  type = "integer",
  default = 1,
  requires = { "HW_MCU_AT91SAM7X" },
  file = "include/cfg/arch.h"
 }

This way, any code, that is relevant to all AT91 chips can use

 #ifdef MCU_AT91

those parts relevant to all SAM7X devices use

 #ifdef MCU_AT91SAM7X

and finally code, that is relevant to the 256k flash version only uses
the original

 #ifdef MCU_AT91SAM7X256

Would that help?

Even if not, I have one hint:

> forced_macro = "HW_BOARD_HEADER",
...
> #if defined(HW_BOARD_HEADER)
> #include HW_BOARD_HEADER
> #endif

I kept symbols starting with HW_ exclusively reserved for hardware
provisions/requirements in the Configurator. IMHO, this makes it easier
to handle the large number of symbols in the configuration files,
specifically with global searching. I never use macro names starting
with HW_.

Regards,

Harald



More information about the En-Nut-Discussion mailing list