C++ wrappers

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome.
gclarkii
Posts: 5
Joined: Wed Mar 01, 2017 7:38 pm
Been thanked: 1 time

Re: C++ wrappers

Postby gclarkii » Tue Sep 19, 2017 8:16 am

Korken wrote:
gclarkii wrote:Greetings,

NOTE: I'm using Msys2 as my build environment as Eclipse with the GNU-arm system died/was way too slow. I'd used FreeBSD for years so...

I've been testing cpp-wrapper-patch-20160729 in a custom project based on the demo for the Nucleo64-F303RE.
I'm using a main.cpp semi-based on the G++ discovery main.cpp using exceptions but no rtti. This is using the trunk, where chprintf.c has moved to streams, arrgghhhh. That was the only pain so far. I also had to mod the doc dir to add a Var and add all the stuff in.

I'm using arm-none-eabi-gcc.exe (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]

I've got over 10 C++ files, 4 of them using exceptions.
I've not used virtual functions yet, so can't see how they work.
So far the code "bloat" has been minimal.

I'll keep testing and hope that Giovanni patches the cpp_wrappers, updates the demos for chprintf.c and updates the doc directories.

GB Clark II

I'd not recommend using exceptions in an MCU, only the extra code needed for rewinding the stack is about 60-70 kB.

With that said, I generally use these flags for C++ projects on embedded to disable stuff I don't want.

Code: Select all

-fno-rtti -fno-non-call-exceptions -fno-exceptions -fno-threadsafe-statics


Sure on a lower end MCU I would not be using exceptions, but my 303RE has plenty of space and I'm able to code my C++ as I'm used to. That said, it seems that the newer G++ flash usage is much lower than it used to be. I know your 60-70 kB estimate is for an older chain, as my .bin size with 5 c++ source files using exceptions is 33kB. NOTE: Just for giggles I triggered an exception and it works, my printf in the catch shows it. Now mind you, I'm not about to use the normal STL, but as the main problems there are dynamic storage, a custom container class should allow the usage of most of the rest.

And as an exceptions should ONLY be used for errors, I don't see the problem. Please note, I have a custom exception class and only my library uses exceptions. I catch in my main and print the reason (if in debug mode), light the led on, and shutdown the program.

GB Clark II

User avatar
Korken
Posts: 256
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 » Tue Oct 24, 2017 6:16 am

Bump on the C++ wrappers

gclarkii
Posts: 5
Joined: Wed Mar 01, 2017 7:38 pm
Been thanked: 1 time

Re: C++ wrappers

Postby gclarkii » Thu Nov 16, 2017 1:07 am

Hello,

I've not worked on my code in a couple of weeks, but so far everything just works. I'm not using anything real fancy, so...

namespaces, objects, exceptions, templates, virtual classes, etc... All working and except for exceptions, none of it has little to no implications for run time. Yes, even virtual classes do not seem to hit the system.

GB

User avatar
Korken
Posts: 256
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 » Sun Dec 03, 2017 11:09 am

Bumpeli bump :)
How is it coming along Giovanni?

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

Re: C++ wrappers

Postby Giovanni » Sun Dec 03, 2017 12:49 pm

Trunk changed, patches do not work, could you post the wrapper simply zipped?

Giovanni

User avatar
Korken
Posts: 256
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 » Sun Dec 03, 2017 1:01 pm

Do you want me to remake the patch based on trunk?
What is not working?

Else just roll back until the patch works with Git and do an recursive merge forward.
It will probably fix itself then.

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

Re: C++ wrappers

Postby Giovanni » Sun Dec 03, 2017 2:50 pm

Just post the files, thanks.

Giovanni

User avatar
Korken
Posts: 256
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 » Mon Dec 04, 2017 9:51 pm

Here is the original patch together with the fixes to syscalls.
Attachments
syscalls_cpp.cpp.zip
(443 Bytes) Downloaded 4 times
cpp-wrapper-patch-20160729.zip
(21.15 KiB) Downloaded 6 times

gclarkii
Posts: 5
Joined: Wed Mar 01, 2017 7:38 pm
Been thanked: 1 time

Re: C++ wrappers

Postby gclarkii » Thu Dec 14, 2017 1:53 pm

Hello,

Got a question, is there a GOOD reason for the C++ Wrapper to be in the mainline area? If it went to Contrib it could be updated much easier with out putting the load on Giovanni.

GB

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

Re: C++ wrappers

Postby Giovanni » Thu Dec 14, 2017 1:55 pm

If you want you could put in community but I do plan to review it.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 1 guest