-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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 #4028
Comments
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. |
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. |
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.
Is there any wiki, list, or documentation on the detail c++ support? I appreciate your input really and thank you in advance... |
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. |
Thank you, @andyross , I just tried this simple C++ program with the newlib to check the new/delete operators, however I get a strange result. Can you please take a quick look on the issue? in prj.conf:
in main.cpp:
output: [QEMU] CPU: cortex-m3 |
new and delete aren't implemented. |
Thank you, @andrewboie I commented out the stubs at the bottom of include/kernel.h, and tried to cross compile the code above with the GCC ARM Embedded Here is the error I receive about the undefined new/delete operators. However, I was expecting the build of the application using the new/delete operators available in the GCC ARM Embedded compiler. But it still looks for the overloaded operators in the kernel.h. Could you please advice on this? Is this the right expectation? Shall I config anything else for the cross compile? I just followed the instructions here. I truly appreciate your input.
|
@andrewboie @andrewboie Any thoughts on this issue is highly appreciated. |
It would be very helpful if there was a little bit more than this to understand better how to use C++ with Zephyr and which C++ standard is actually supported. Maybe I'm overlooking something here. Could anyone provide further details about which C++ standard (98, 03, 11, ...?) is currently supported and maybe give a tiny |
@mrusme The application in There are still significant limitations including use of dynamic object creation, virtual functions, and exceptions. Any or all of them may work in some circumstances, configurations, and tool chains. |
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?
This will open a great space to deploy c++ applications on Zephyr too. I appreciate any input.
Thank you.
(Imported from Jira ZEP-2599)
The text was updated successfully, but these errors were encountered: