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: 2
Joined: Wed Mar 01, 2017 7:38 pm

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


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 2 guests