Thread, mutex, condition_variable on RA4 ARM Cortex-M33

Hi, we are busy deciding which route to go with these micros and our project. I am trying to port a library from another product and am having a few problem. 

Is it possible to have a C++11 based project that uses std::mutex, std::thread and std::condition_variable etc

It seems the toolchain support it, if the header files are all available, but it is not compiling in the code as getting the following errors below

..\src\JobQueue.cpp:158:27: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
..\src\JobQueue.cpp:158:27: error: 'mutex' is not a member of 'std'

..\src\JobQueue.h:20:1: note: 'std::thread' is defined in header '<thread>'; did you forget to '#include <thread>'?
..\src\JobQueue.h:148:22: error: 'thread' is not a member of 'std'

I am building in e2Studio. What am I missing? Do I need to enable these features in the settings/compiler options? Do I need to use an RTOS? Or can I do this on a BareMetal system?

Any advice would be appreciated.

Thanks.

Parents
  • You should wrte a C++ wrapper for each RTOS object thar has a C++ api that you will use in your code. Each .cpp and .h will include the ThreadX call using tue C api. So you'll have mutex.cpp, thread.cpp, etc and the corresponding .h file for each. Each cpp will interface to the RTOS app using cpp to c calling conventions.   If you google, you should be able to find this done by others.

    An alternative wpuld be one rtos.cpp/.h that has all the RTOS api's exposed in each method. 

    You can make this wrapper a static class, or singleton.

Reply
  • You should wrte a C++ wrapper for each RTOS object thar has a C++ api that you will use in your code. Each .cpp and .h will include the ThreadX call using tue C api. So you'll have mutex.cpp, thread.cpp, etc and the corresponding .h file for each. Each cpp will interface to the RTOS app using cpp to c calling conventions.   If you google, you should be able to find this done by others.

    An alternative wpuld be one rtos.cpp/.h that has all the RTOS api's exposed in each method. 

    You can make this wrapper a static class, or singleton.

Children