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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: C++ wrappers

Post by Giovanni »

Hi,

You should work using subversion trunk code, 16.1 is a stable branch and will not receive any enhancement, only bug fixes.

Other questions are likely explained here: http://chibios.org/dokuwiki/doku.php?id ... tyle_guide
The document is meant for C, it could require changes in order to address C++ too.

Giovanni
helmut
Posts: 18
Joined: Thu Apr 07, 2016 9:06 am
Has thanked: 1 time
Been thanked: 3 times

Re: C++ wrappers

Post by helmut »

Hi,

I just stumbled over a trouble which I was expecting when rebasing to trunk.
'trunk' as svn://svn.code.sf.net/p/chibios/svn/trunk@9602 just does not compile RT-STM32F407-DISCOVER-G++,
making it hard to test my changes.

Questions 2, 4, 9 and probably 10 are still open.
Helmut
helmut
Posts: 18
Joined: Thu Apr 07, 2016 9:06 am
Has thanked: 1 time
Been thanked: 3 times

Re: C++ wrappers

Post by helmut »

Hi Jovanni,

just went through the coding style (again). I just wonder: Is there a reason for pressing C89 :shock:
it is just ANCIENT, it might be legitimate not to go C11, but at least I know of no single C-compiler,
that does not support C99 (which is 17 years old :roll:)

Helmut
PS: I don't want to start a flame war here, I'm just curious.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: C++ wrappers

Post by Giovanni »

Hi,

Products are meant to be portable, if you go outside the ARM perimeter there are proprietary compilers that do not support C99.

Giovanni
helmut
Posts: 18
Joined: Thu Apr 07, 2016 9:06 am
Has thanked: 1 time
Been thanked: 3 times

Re: C++ wrappers

Post by helmut »

Hi,

I'm having hard times to rebase the wrappers to trunk, stumbling over compile errors again and again ...

Code: Select all

../../../os/hal/src/hal_usb.c: In function 'usbStop':
../../../os/hal/src/hal_usb.c:324:3: error: 'spip' undeclared (first use in this function)
   spip->config = NULL;
   ^
../../../os/hal/src/hal_usb.c:324:3: note: each undeclared identifier is reported only once for each function it appears in
make: *** [build/obj/hal_usb.o] Error 1
helmut@daredevil:~/work/tpd02/chHALE/ChibiOS/demos/STM32/RT-STM32F746G-DISCOVERY-LWIP-FATFS-USB$


Helmut
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: C++ wrappers

Post by Giovanni »

Hi,

Fixed that error, it was caused by a recent change.

Giovanni
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: C++ wrappers

Post by Prof. Dr. YoMan »

Hi,

I just want to point on this: https://community.arm.com/groups/tools/ ... itten-in-c

Gaining C++11 compatible threading and lots of STL functionality is really nice.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: C++ wrappers

Post by Giovanni »

Interesting, still a proposal but I think we should keep an eye on it and try to influence it for the better.

I think that the core should stay written in C and provide a C++ wrapper, current approach. I don't see advantages in writing directly in C++ and it would impact portability.

Giovanni
helmut
Posts: 18
Joined: Thu Apr 07, 2016 9:06 am
Has thanked: 1 time
Been thanked: 3 times

Re: C++ wrappers

Post by helmut »

Giovanni wrote:Hi,

Fixed that error, it was caused by a recent change.

Giovanni


Hi,
in which commit?

... OK, just saw it its 9610, sorry.

The question now is, how is often is the github mirror updated?

Helmut
Last edited by helmut on Tue Jun 14, 2016 12:27 pm, edited 2 times in total.
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: C++ wrappers

Post by Prof. Dr. YoMan »

It is not only a proposal. Check the git-repos on github.
http://micro-os-plus.github.io/cmsis-plus/ and some others.

From what I know from Liviu it already runs in the simulator and passes the CMSIS-RTOS test suite.
And there is a working version with FreeRtos as sheduler. He is answering mails pretty fast. Maybe ask direcly (with link to this thread).

From my point of view the step to C++11 and above is the only possible solution, because this is the first "complete" version of C++ which is broadly compatible on different compilers and which got a reeeeealy got Lib and API.

Every thing is very well though. Check the books "A Tour of C++" by Stroustrup, "The C++ Standard Library" by Jusuttis and
http://isocpp.github.io/CppCoreGuidelin ... Guidelines / https://github.com/isocpp/CppCoreGuidelines
and
https://github.com/Microsoft/GSL

uC these days are big enough to handle this well and it is not true that C++ is a memory hog or that everything is done dynamically. Building on templates and C++11 STL one could easily build stuff without any dynamic memory allocation, completely checked static by compiletime.

Great for embedded stuff.

C++11 and above is the way to go.
Post Reply