C++ wrappers

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome.
szekelyisz
Posts: 3
Joined: Wed Jan 03, 2018 8:15 pm

Re: C++ wrappers

Postby szekelyisz » Tue Jan 30, 2018 8:37 pm

Korken,

What's the reason for declaring most of the classes final? IMHO it takes out the elegancy from interfacing ChibiOS with C++. For example, with the old wrapper you could derive a class from BaseStaticThread, define a main() member function and call any thread-related function implicitly against the this pointer. Now you have to store a reference to the Thread object and prefix all calls with that member. For now I don't see a reason why these classes need to be final. Without that you would still have the freedom to choose between inheritance or referencing.

Thanks, Szabi

User avatar
Korken
Posts: 270
Joined: Wed Apr 02, 2014 4:09 pm
Location: Luleå, Sweden
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: C++ wrappers

Postby Korken » Fri Feb 02, 2018 10:45 am

szekelyisz wrote:Korken,

What's the reason for declaring most of the classes final? IMHO it takes out the elegancy from interfacing ChibiOS with C++. For example, with the old wrapper you could derive a class from BaseStaticThread, define a main() member function and call any thread-related function implicitly against the this pointer. Now you have to store a reference to the Thread object and prefix all calls with that member. For now I don't see a reason why these classes need to be final. Without that you would still have the freedom to choose between inheritance or referencing.

Thanks, Szabi

This comes from the changes made in the beginning of these new wrappers, and I had the same question as you.
But helmut had good points about it: viewtopic.php?f=3&t=3287&start=50#p27048

Also, your should really not be using virtual inheritance any more. There is a really good talk on YouTube from one of the latest C++ conferences, I will try to find it.
Use a std::variant for all supported types instead or CRTP, I have yet to find a case where I really needed virtual inheritance in embedded.

However, if a use case is found that cannot be within this style, please provide it and we can look at updating the interface.


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 4 guests