[En-Nut-Discussion] Extending device structures, was Re: Problem with STM32 pin ...

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue Oct 6 21:41:18 CEST 2015

Hi Uwe,

Am 06.10.2015 um 17:20 schrieb Uwe Bonnes:
>>>>>> "Ole" == Ole Reinhardt <ole.reinhardt at embedded-it.de> writes:
>     Ole> The above changes should not cause damage to others, but I'd like
>     Ole> to suggest to apply these changes to _all_ spi bus drivers, not
>     Ole> only to our stm32_spi driver and initialise them with NULL, where
>     Ole> not needed.
> For structure initialization, is there anything against initializing like
> NUTDEVICE devStm32Lcd16Seg = {
>     .dev_name = {'1','6', 'S', 'E', 'G', 0, 0, 0},

> versus the old way:
> NUTI2C_BUS i2cBus2Stm32 = {
>     &i2c2cb,    /* bus_icb */

If you ask ME, I would always vote to use named structure
initialisation. But keep in mind, that this is C99 standard, not C89.

Quite some time ago, Harald asked me to not use this kind of structure
initialisations in code, that is used globally. Doing so in CM3 code,
which requires to use the GCC anyway is fine, but not in placed that
could perhaps also be compiled with some esoteric compiler.

AFAIK he uses some of the Nut/OS code on platforms like the VS10xx DSPs,
where the compiler only supports C89.



> With dot-initialization, we don't need to explicitly write NULL or 0 for the
> structure elements we don't need, and it is self documenting. The ordered
> initialization however needs us to write NULL/0 entries and to write
> comments for documentation that can get easy out of sync.
> Is there any compiler we still care for that does not support the
> dot-initialization for stuctures?
> Harald, any comments on extending structures and structure initialization?
> Bye

kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen

More information about the En-Nut-Discussion mailing list