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

Untagged structs in ChibiOS  Topic is solved

Postby dflogeras » Sat Sep 22, 2018 2:11 pm

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Untagged structs in ChibiOS

Postby Giovanni » Sat Sep 22, 2018 4:31 pm

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: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: Untagged structs in ChibiOS

Postby dflogeras » Sun Sep 23, 2018 5:37 pm

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 193 times

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: Untagged structs in ChibiOS

Postby dflogeras » Sat Nov 17, 2018 4:12 pm

Another patch, as above, but for untagged I2CConfig structs

i2c_config_untagged_struct.zip
(938 Bytes) Downloaded 192 times

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Untagged structs in ChibiOS

Postby Giovanni » Tue Dec 11, 2018 9:09 am

Hi,

This problem is being addressed in all drivers for consistency.

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 6 guests