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
C++ wrappers
- 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:
-
- Posts: 38
- Joined: Sat Jan 10, 2015 10:12 pm
- Has thanked: 1 time
- Been thanked: 1 time
Re: C++ wrappers
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
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
- 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
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
Please test it as much as possible before then.
Giovanni
- 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
Hi all,
How is it going with this? I just pulled latest and it seems that the cpp wrappers are still not merged.
How is it going with this? I just pulled latest and it seems that the cpp wrappers are still not merged.
- 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
Hi,
Currently I have little time to review it, lot of other things are queued as well. It is not forgotten
Giovanni
Currently I have little time to review it, lot of other things are queued as well. It is not forgotten
Giovanni
Re: C++ wrappers
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
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
- 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
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
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
- 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
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
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