Untagged structs in ChibiOS Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Untagged structs in ChibiOS

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Untagged structs in ChibiOS

Post 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
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: Untagged structs in ChibiOS

Post 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
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: Untagged structs in ChibiOS

Post by dflogeras »

Another patch, as above, but for untagged I2CConfig structs

i2c_config_untagged_struct.zip
(938 Bytes) Downloaded 690 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Untagged structs in ChibiOS

Post by Giovanni »

Hi,

This problem is being addressed in all drivers for consistency.

Giovanni
Post Reply