Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ on the boards #1323

Closed
BytesGalore opened this issue Jun 15, 2014 · 38 comments
Closed

C++ on the boards #1323

BytesGalore opened this issue Jun 15, 2014 · 38 comments
Assignees
Labels
Area: C++ Area: C++ wrapper Community: good first issue This issue is good for newcomers to RIOT to be addressed / implemented Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: AVR Platform: This PR/issue effects AVR-based platforms Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: native Platform: This PR/issue effects the native platform Type: new feature The issue requests / The PR implemements a new feature for RIOT Type: tracking The issue tracks and organizes the sub-tasks of a larger effort

Comments

@BytesGalore
Copy link
Member

BytesGalore commented Jun 15, 2014

RIOT now provides a seamless c and c++ handling in the RIOT build system for user applications.
But using c++ on specific boards requires adjustments, e.g. (un)set specific compiler and linker flags, provide/change system calls or even provide a custom tweaked compiler.

Here we can track the progression of board support and discuss related issues.

  • Family: native
    • native
  • Family: ARM
    • Airfy Beacon
    • Arduino Due
    • cc2538dk
    • f4vi1
    • IoT LAB_M3
    • mbed_lpc1768
    • MSB-IoT
    • MSBA2
    • Mulle
    • OpenMote
    • PCA1000x
    • Phytec phyWAVE KW22
    • Samr21 xpro
    • Spark Core
    • STM32F0discovery
    • STM32F3discovery
    • STM32F4discovery
    • UDOO
    • yunjia-nrf51822
  • Family: ATmega
    • Arduino Mega2560
    • Arduino Uno
    • Arduino Duemilanove
  • Family: MSP430
    • eZ430-Chronos
    • MSB-430H
    • TelosB
    • WSN430
    • Zolertia Z1
  • Family: x86
    • Intel Galileo
@BytesGalore
Copy link
Member Author

Family: ARM compile tests

  • pttu w/ MCU lpc2387 (compiles)
  • avsextrem w/ MCU lpc2387 (compiles)
  • redbee-econotag w/ MCU mc1322x (Does NOT compile, errors)
./RIOT/cpu/mc1322x/include/mc1322x.h:26:10: error: 'struct CRM_struct::<anonymous union>::CRM_SYS_CNTL' invalid; an anonymous union can only have non-static data members [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:200:66: error: invalid conversion from 'void*' to 'volatile CRM_struct*' [-fpermissive]
./RIOT/cpu/mc1322x/include/mc1322x.h:223:10: error: 'struct TMR_struct::<anonymous union>::TMR_CTRL' invalid; an anonymous union can only have non-static data members [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:292:69: error: invalid conversion from 'void*' to 'volatile TMR_struct*' [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:332:24: error: 'struct ITC_struct::<anonymous union>::ITC_INTCNTL' invalid; an anonymous union can only have non-static data members [-fpermissive]
...
./RIOT/cpu/mc1322x/include/mc1322x.h:342:9: note: in expansion of macro '__INTERRUPT_union'
...
/RIOT/cpu/mc1322x/include/mc1322x.h:354:66: error: invalid conversion from 'void*' to 'volatile ITC_struct*' [-fpermissive]

@dangnhat
Copy link
Member

ping @BytesGalore : do we have any progress on this ? ;-)

@BytesGalore
Copy link
Member Author

no, I haven't tested the implementation for some time if something changed 😊
I will extend the list for with the new boards tomorrow and update it with current results.

@N8Fear
Copy link

N8Fear commented Oct 30, 2014

For AVR I think I can say that there seems is currently no real C++ support on the side of avr-libc. Especially libstdc++ is missing. So while it is possible to use language constructs like classes (I'm not sure if a C++ compiler is included in the default toolchain, Gentoo's crossdev builds one), C++ experience on AVR won't be seamless (without extensive work or switching to another libc, which implies extensive work again ;-) ).

@LudwigKnuepfer
Copy link
Member

Arch Linux comes with avr-g++.

@jnohlgard
Copy link
Member

@N8Fear It is not really viable to expect a full libstdc++ or similar on a microcontroller platform because of flash and RAM considerations, but there are lighter alternatives for a C++ template library if just the C++ support is there, e.g. http://msharov.github.io/ustl/ (I haven't tried that one yet, but I have been meaning to do it for some time)

@N8Fear
Copy link

N8Fear commented Oct 30, 2014

Ok - in this case: If C++ support means "there is a compiler" AVR should be fine.. ;-)

@dangnhat
Copy link
Member

@N8Fear : at least we want some basic object-oriented programming can be done, after that we can consider the support for other stuffs like STL (after evaluate the resource needed and real-time capacity on uCs ). ;-)

For AVR I think I can say that there seems is currently no real C++ support on the side of avr-libc.

IMHO, I think it's the problem with C++ support on that platform in general not specific RIOT. I guess our main goal should be providing the build system to build C++ easily and making sure our source code don't do anything to violate C/C++ compatibility. In other words, it's something like "if some people can use C++ on a platform then they can use C++ with RIOT like normal because our build system can mix their code with RIOT and we don't mess anything up with C/C++ compatibility" ;-)

C++ experience on AVR won't be seamless (without extensive work or switching to another libc,
which implies extensive work again ;-) )

Therefore, if the "normal situation on a specific platform" has some difficulties with C++ then provide the better C++ support for that platform should be nice to have for RIOT but not mandatory. :-)

BTW, arduino can do some C++ programming on avr, right?

@N8Fear
Copy link

N8Fear commented Oct 31, 2014

BTW, arduino can do some C++ programming on avr, right?

Honestly I don't know, but since the AVR arduinos use avr-libc themselves I guess that if it is possible, it's limited the same way as for us (no stdlib).

@dangnhat
Copy link
Member

@gebart :

http://msharov.github.io/ustl/

I also haven't tried this one but it looks really nice. I have a C++ project on RIOT with stm32 so I'll try it out. ;-)
Thanks.

@dangnhat
Copy link
Member

it's limited the same way as for us (no stdlib).

yeah, I have looked into some forums, it seems to be quite limited. I guess when we have time, we should get one and find out by ourselves. :D

@dangnhat
Copy link
Member

Because the deadline of my thesis is closing in, I will postponed the C++ support for msp430 and avr for several weeks, and the C++ support for these platforms probably can't make it into next release. I'll come back with this topic in 2, 3 weeks.
Cheers,

@haukepetersen
Copy link
Contributor

Just successfully tested for the mbed_lpc1768.

@BytesGalore
Copy link
Member Author

@dangnhat good luck for your thesis!
I will take a look on eZ430-Chronos, as we have this HW here. The TI toolchain for msp in >=4.9 seems to be very complete with c++ support (I had just a quick look) and maybe we can manage to build RIOT with it for the board.

@dangnhat
Copy link
Member

@haukepetersen : good new! :D
@BytesGalore : thanks! Did you mention about proprietary TI compiler, or Red hat & TI's MSP430-gcc or community's MSPGCC? ;-) (Just out of curiousity )

@BytesGalore
Copy link
Member Author

@dangnhat The Red hat one.

@kausthub
Copy link

kausthub commented Mar 9, 2015

hi i am a new comer , can you help me on how to get started with this issue ? few links or what am i looking to resolve ?
thanks in advance

@OlegHahm OlegHahm assigned josephnoir and unassigned dangnhat Mar 10, 2015
@miri64 miri64 added the Platform: AVR Platform: This PR/issue effects AVR-based platforms label Sep 1, 2018
@miri64 miri64 added Community: good first issue This issue is good for newcomers to RIOT to be addressed / implemented and removed x86 labels Sep 30, 2018
@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@stale stale bot closed this as completed Sep 10, 2019
@fjmolinas
Copy link
Contributor

This should have had tracking Issue Tag, should not have been closed. Re-open.

@fjmolinas fjmolinas reopened this Sep 13, 2019
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Sep 13, 2019
@fjmolinas fjmolinas added the Type: tracking The issue tracks and organizes the sub-tasks of a larger effort label Sep 13, 2019
@mfp20
Copy link

mfp20 commented May 10, 2020

For AVR, this guys did an awesome job. It generates a fairly complete C++ lib for the target, and they are focused on performance. It could be a good companion for RIOT.

The only annoying thing is their extensive use of C++17 features, forcing the use of avr-gcc v7+; all major distros are stuck at v5.4 or alike, so a custom toolchain must be built. They distribute a pre-made v9.2 toolchain tough.
There's a big question mark about the future, because GCC will disable AVR target in v10 and remove in v11. And llvm avr target is unstable.

@miri64
Copy link
Member

miri64 commented Jun 30, 2020

@mfp20 would you be interested in looking into porting this e.g. as a package? The caveats can be dealt with later as long as there is documentation on it.

@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 21, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@maribu
Copy link
Member

maribu commented Sep 16, 2022

Basic C++ support on RIOT is working on pretty much every board (except native on FreeBSD or so?). With the ETL package even a usable standard template lib exists.

More native C++ wrappers for the C APIs that do make use of C++ features such as OOP, RAII, etc. where sensible would be nice, but that is orthogonal to this issue.

Also, some platforms are still missing a C++ standard lib, at least AVR does. For AVR https://github.com/modm-io/avr-libstdcpp could be used. But I personally do not feel the itch to package that to just tick a box. If there would be users actually needing this, I could be motivated to do so.

IMO this issue can be closed. Even thought there are still areas of improvement for C++ users, IMO new issues that are more explicit and focused on a single issue should be opened instead.

But if someone disagrees: Feel free to reopen.

@maribu maribu closed this as completed Sep 16, 2022
@mfp20
Copy link

mfp20 commented Sep 16, 2022

@miri64 I apologize, I must have missed the notification mail of your message in 2020. I've just noted the thread now, on closing by @maribu. I am currently not using RIOT, relying on readily available firmware for my application, just for simple time/money availability constraints (in my life). So no, can't develop anything isn't a paid commercial project. But I hope to be able to change this whenever possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C++ Area: C++ wrapper Community: good first issue This issue is good for newcomers to RIOT to be addressed / implemented Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: AVR Platform: This PR/issue effects AVR-based platforms Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: native Platform: This PR/issue effects the native platform Type: new feature The issue requests / The PR implemements a new feature for RIOT Type: tracking The issue tracks and organizes the sub-tasks of a larger effort
Projects
None yet
Development

No branches or pull requests