C++ wrappers

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: C++ wrappers

Postby Giovanni » Tue Jan 31, 2017 11:36 am

Hi,

I will move this to 17.2.1 together with the new lwIP integration, I wish to close this 17.2.0 release in february, it is long overdue.

Giovanni

charlesrwest
Posts: 38
Joined: Sat Jan 10, 2015 10:12 pm
Has thanked: 1 time
Been thanked: 1 time

Re: C++ wrappers

Postby charlesrwest » Sat Feb 11, 2017 5:32 pm

Hello all,

I would like to report a bug fix for C++ with ChibiOS. I was working with a simple hello world program compiled with cpp but without any C++ features (using direct OS calls, not the wrapper) and got linker errors (originally reported in this thread in Sept 2015, viewtopic.php?f=24&t=2842). It appears possible to solve this issue by adding "__attribute__((used))" to void _exit(int status), pid_t _getpid(void), and int _kill(int pid, int sig).

I've attached the example project and the fixed syscalls_cpp.cpp file. If I may ask, would it be possible to incorporate the change into the next release?

Thanks,
Charlie West
Attachments
syscalls_cpp.cpp.zip
(443 Bytes) Downloaded 236 times
GoodBotFirmware.zip
(4.22 MiB) Downloaded 247 times

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

Re: C++ wrappers

Postby Giovanni » Sat Feb 11, 2017 5:37 pm

Sure, please put all updates and feedback in this thread. The wrapper should go in 17.2.1.

Please test it as much as possible before then.

Giovanni

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 » Sat Jul 01, 2017 10:26 am

Hi all,
How is it going with this? I just pulled latest and it seems that the cpp wrappers are still not merged.

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

Re: C++ wrappers

Postby Giovanni » Sat Jul 01, 2017 2:30 pm

Hi,

Currently I have little time to review it, lot of other things are queued as well. It is not forgotten :)

Giovanni

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 » Wed Jul 12, 2017 8:31 am

Ah okey, is there any time plan for merging them? :)

gclarkii
Posts: 24
Joined: Wed Mar 01, 2017 7:38 pm
Has thanked: 1 time
Been thanked: 2 times

Re: C++ wrappers

Postby gclarkii » Tue Sep 05, 2017 10:59 am

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

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

Re: C++ wrappers

Postby Giovanni » Tue Sep 05, 2017 11:02 am

Hi,

Keep giving feedback, it will be integrated at some point, I need to find time to learn it because it is quite different from the old one.

Giovanni

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 » Sun Sep 17, 2017 12:30 pm

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

gclarkii
Posts: 24
Joined: Wed Mar 01, 2017 7:38 pm
Has thanked: 1 time
Been thanked: 2 times

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 16 guests