Date
1 - 4 of 4
CPP support
Guy Morand
Hi Zephyr users!
I'm new to Zephyr and was asked to write a small "study" project in c++. I didn't find much in the documentation about c++, except one sample and the following page: https://docs.zephyrproject.org/latest/reference/kernel/other/cxx_support.html I'm using the Zephyr SDK 0.13.2 and I started with: ``` #include <memory> void main(void) { std::unique_ptr<int> intValue = std::make_unique<int>(1234); while(1) { ; } } ``` My prj.conf contains: ``` CONFIG_CPLUSPLUS=y CONFIG_STD_CPP20=y ``` Unfortunately, it doesn't build although I can find the <memory> header file in the SDK: ``` main.cpp:6:10: fatal error: memory: No such file or directory 6 | #include <memory> | ^~~~~~~~ ``` * Am I missing something? * Is the current cpp status is very limited and should avoid standard library? (what would makes sense :D) Kind regards, Guy |
|
Guy Morand
Yes, it works with:
toggle quoted message
Show quoted text
``` CONFIG_NEWLIB_LIBC=y CONFIG_CPLUSPLUS=y CONFIG_STD_CPP20=y CONFIG_LIB_CPLUSPLUS=y ``` Thanks a lot for the pointers! Regards, Guy On 15/12/2021 08:30, Kim Boendergaard wrote:
I think you are missing CONFIG_LIB_CPLUSPLUS=y --
bytes at work Technoparkstrasse 7 CH-8406 Winterthur Switzerland phone: +41 52 213 79 79 |
|
Kim Boendergaard <kim.boendergaard@...>
I think you are missing CONFIG_LIB_CPLUSPLUS=y
toggle quoted message
Show quoted text
When it comes to threads (and semaphores, mutex etc) the Zephyr implementation is lacking a bit, but except from that it is working fine. We have made our own C++ versions of semaphores, mutex etc based on the Zephyr kernel API. Usage of iostream takes up a lot of flash resources Best regards, Kim Bøndergaard -----Original Message-----
From: users@... <users@...> On Behalf Of Guy Morand Sent: Tuesday, 14 December 2021 17.22 To: Zephyr-users@... Subject: [Zephyr-users] CPP support EXTERNAL — Use caution when opening link(s) or attachment(s) ________________________________ Hi Zephyr users! I'm new to Zephyr and was asked to write a small "study" project in c++. I didn't find much in the documentation about c++, except one sample and the following page: https://urldefense.com/v3/__https://docs.zephyrproject.org/latest/reference/kernel/other/cxx_support.html__;!!KHGsRxShrw!q__J4PjhnarC-Jb1FvV4Wwd6ge_OL5p7ZPC38_w0Agi5c7hMfT_zp-SLVDmfr3bDSstITFXG$ I'm using the Zephyr SDK 0.13.2 and I started with: ``` #include <memory> void main(void) { std::unique_ptr<int> intValue = std::make_unique<int>(1234); while(1) { ; } } ``` My prj.conf contains: ``` CONFIG_CPLUSPLUS=y CONFIG_STD_CPP20=y ``` Unfortunately, it doesn't build although I can find the <memory> header file in the SDK: ``` main.cpp:6:10: fatal error: memory: No such file or directory 6 | #include <memory> | ^~~~~~~~ ``` * Am I missing something? * Is the current cpp status is very limited and should avoid standard library? (what would makes sense :D) Kind regards, Guy [The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Any unauthorized use, disclosure, reproduction, copying, distribution, or other form of unauthorized dissemination of the contents is expressly prohibited. If you have received this communication in error, please notify the sender immediately by email and delete the original message. Opinions, conclusions and other information in this message represent the opinion of the sender and do not necessarily represent or reflect the views and opinions of Esco Lifesciences Group companies.] |
|
Any consideration in upstreaming the C++ versions of the semaphores and mutexs?
toggle quoted message
Show quoted text
-----Original Message-----
From: users@... <users@...> On Behalf Of Kim Boendergaard via lists.zephyrproject.org Sent: Wednesday, December 15, 2021 1:30 AM To: Guy Morand <guy.morand@...>; Zephyr-users@... Subject: Re: [Zephyr-users] CPP support I think you are missing CONFIG_LIB_CPLUSPLUS=y When it comes to threads (and semaphores, mutex etc) the Zephyr implementation is lacking a bit, but except from that it is working fine. We have made our own C++ versions of semaphores, mutex etc based on the Zephyr kernel API. Usage of iostream takes up a lot of flash resources Best regards, Kim Bøndergaard -----Original Message----- From: users@... <users@...> On Behalf Of Guy Morand Sent: Tuesday, 14 December 2021 17.22 To: Zephyr-users@... Subject: [Zephyr-users] CPP support EXTERNAL - Use caution when opening link(s) or attachment(s) ________________________________ Hi Zephyr users! I'm new to Zephyr and was asked to write a small "study" project in c++. I didn't find much in the documentation about c++, except one sample and the following page: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fdocs.zephyrproject.org%2Flatest%2Freference%2Fkernel%2Fother%2Fcxx_support.html__%3B!!KHGsRxShrw!q__J4PjhnarC-Jb1FvV4Wwd6ge_OL5p7ZPC38_w0Agi5c7hMfT_zp-SLVDmfr3bDSstITFXG%24&data=04%7C01%7Cdavid.leach%40nxp.com%7C375d986cd81b430ece7d08d9bfc5b672%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C637751678161294067%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KxWvulJLRIlpVEki%2F9dDofmAa0l1LaVlbeKUyFMVCkk%3D&reserved=0 I'm using the Zephyr SDK 0.13.2 and I started with: ``` #include <memory> void main(void) { std::unique_ptr<int> intValue = std::make_unique<int>(1234); while(1) { ; } } ``` My prj.conf contains: ``` CONFIG_CPLUSPLUS=y CONFIG_STD_CPP20=y ``` Unfortunately, it doesn't build although I can find the <memory> header file in the SDK: ``` main.cpp:6:10: fatal error: memory: No such file or directory 6 | #include <memory> | ^~~~~~~~ ``` * Am I missing something? * Is the current cpp status is very limited and should avoid standard library? (what would makes sense :D) Kind regards, Guy [The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Any unauthorized use, disclosure, reproduction, copying, distribution, or other form of unauthorized dissemination of the contents is expressly prohibited. If you have received this communication in error, please notify the sender immediately by email and delete the original message. Opinions, conclusions and other information in this message represent the opinion of the sender and do not necessarily represent or reflect the views and opinions of Esco Lifesciences Group companies.] |
|