Page 7 of 9

Re: C++ wrappers

Posted: Tue Jan 31, 2017 11:36 am
by Giovanni
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

Re: C++ wrappers

Posted: Sat Feb 11, 2017 5:32 pm
by charlesrwest
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

Re: C++ wrappers

Posted: Sat Feb 11, 2017 5:37 pm
by Giovanni
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

Re: C++ wrappers

Posted: Sat Jul 01, 2017 10:26 am
by Korken
Hi all,
How is it going with this? I just pulled latest and it seems that the cpp wrappers are still not merged.

Re: C++ wrappers

Posted: Sat Jul 01, 2017 2:30 pm
by Giovanni
Hi,

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

Giovanni

Re: C++ wrappers

Posted: Wed Jul 12, 2017 8:31 am
by Korken
Ah okey, is there any time plan for merging them? :)

Re: C++ wrappers

Posted: Tue Sep 05, 2017 10:59 am
by gclarkii
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

Re: C++ wrappers

Posted: Tue Sep 05, 2017 11:02 am
by Giovanni
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

Re: C++ wrappers

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

Re: C++ wrappers

Posted: Tue Sep 19, 2017 8:16 am
by gclarkii
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