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++ 11 Support #2428

Open
nashif opened this issue Sep 8, 2017 · 4 comments
Open

C++ 11 Support #2428

nashif opened this issue Sep 8, 2017 · 4 comments

Comments

@nashif
Copy link

nashif commented Sep 8, 2017

Reported by Soheil Qanbari:

Hi,

Based on the C++ Support for Applications page:

http://zephyr-docs.s3-website-us-east-1.amazonaws.com/online/dev/kernel/other/cxx_support.html

Is there any plan on when to support the following c++ functionalities?

Dynamic object management with the new and delete operators
Vectors
RTTI
Exceptions
Static global object destruction

This will open a great space to deploy c++ applications on Zephyr too. I appreciate any input.

Thank you.

(Imported from Jira ZEP-2599)

@nashif
Copy link
Author

nashif commented Sep 11, 2017

by Andy Ross:

RTTI and exceptions would be possible with (mostly) just a few compiler flags. Note that both have siginificant code size implications which make them sorta poor choices for an RTOS environment. And like all mixed C/C++ environments, exceptions will be tricky to use in Zephyr: you have to throw them and catch them from within "pure" C++ code. If there is a C function on the stack between your throw and catch (e.g. a driver or network stack callback, etc...) it won't work.

I'd expect new/delete to work normally right now, as-is, as long as you are linking against newlib which includes a (mostly) working malloc. We could wire up k_malloc() for that purpose too, though again most of our targets have a very constrained heap. It hasn't been a priority, but I don't think much would be required to validate this usage.

Not sure what you want a static destructor for. You want to hook the destructors to run at a "system shutdown" moment? We don't have that, though I guess we could add it.

@nashif
Copy link
Author

nashif commented Sep 14, 2017

by Soheil Qanbari:

Thank you, Andy Ross , really. Your reply means a lot to us. :)

We have a little engine and would love to build it for ZEP, as we believe it is the future generation of RTOSs.

I will come back to you shortly with the short list of libraries that we need and would be very thankful for your comment on them.

My sincere thanks again.

@nashif
Copy link
Author

nashif commented Sep 20, 2017

by Soheil Qanbari:

Hi Andy Ross ,

I hope you are doing well. We need the libs for threads, iostream, vector, map, set,... Here are the includes we need to build our engine on the Microcontroller using ZEP.

#include
#include
#include
#include
#include
#include
#include
#include
#include <type_traits>
#include
#include
#include
#include
#include
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include
#include <dlfcn.h>
#include <assert.h>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/stat.h>

Is there any wiki, list, or documentation on the detail c++ support?

I appreciate your input really and thank you in advance...

@nashif
Copy link
Author

nashif commented Sep 20, 2017

by Andy Ross:

There's absolutely no way that all of that is going to be supported. In particular the POSIX-based filesystem stuff doesn't exist in Zephyr. We aren't a unix.

Things that work directly on memory and are header-only libraries (e.g. STL & the rest of the containers and algorithms stuff) should be OK when linked with newlib (which provides the heap). Things that work with the underlying OS are going to need significant porting to work with Zephyr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant