Page 1 of 1

Untagged structs in ChibiOS

Posted: Sat Sep 22, 2018 2:11 pm
by dflogeras
Hi, I've noticed at least one (SPIConfig) untagged struct.

I've been toying with introducing more C++ into my pet projects, and one thing this prevents is doing C++ forward declaration. Is this done for a specific reason in Chibi, or just an oversight/nobody cared until me?

Specifically the difference is between
typedef struct {
...
} SPIConfig;

and

typedef struct SPIConfig {
...
} SPIConfig;

I'd be happy to submit patches, but wanted to ask first in case they have to remain in their current state.

Re: Untagged structs in ChibiOS

Posted: Sat Sep 22, 2018 4:31 pm
by Giovanni
Hi,

Just oversight, C++ for HAL was not a requirement thus not tested. Please feel free to submit patches and, eventually, report other anomalies.

Please avoid giving structure the same name of types, SPIConfig should become hal_spi_config, we use this convention already for RT.

Giovanni

Re: Untagged structs in ChibiOS

Posted: Sun Sep 23, 2018 5:37 pm
by dflogeras
All good,

Here's a patch, it applies cleanly to trunk as well as 17.6.x and 18.2.x branches in case you want to incorporate it into them.

spi_config_untagged_struct.zip
patch for untagged SPIConfig type
(780 Bytes) Downloaded 666 times

Re: Untagged structs in ChibiOS

Posted: Sat Nov 17, 2018 4:12 pm
by dflogeras
Another patch, as above, but for untagged I2CConfig structs

i2c_config_untagged_struct.zip
(938 Bytes) Downloaded 691 times

Re: Untagged structs in ChibiOS

Posted: Tue Dec 11, 2018 9:09 am
by Giovanni
Hi,

This problem is being addressed in all drivers for consistency.

Giovanni