Does gcc support unique_blocks?


I wanted to use streams in my code and thought that the upcoming C ++ 0x extensions would be convenient, as they would eventually become the standard. This seemed reliable in the future without the need for additional libraries such as boost :: thread.
Unfortunately, I could not find useful information about which functions regarding streams are currently supported by gcc. I use unique_locks, which do not work yet. This is the result of the linker:

.build_debug/src/core/simulator.o: In function `Simulator::start(int, int, int, int)': simulator.cpp:(.text+0x1fc): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' .build_debug/src/core/simulator.o: In function `Simulator::resume()': simulator.cpp:(.text+0x351): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' .build_debug/src/core/simulator.o: In function `Simulator::pause()': simulator.cpp:(.text+0x417): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' .build_debug/src/core/simulator.o: In function `Simulator::stop()': simulator.cpp:(.text+0x4cd): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' 

Does anyone understand these messages? I assume that they reference the use of unique_lock. But why do these errors occur?

My source code is similar to the following:
std::unique_lock<std::mutex> lkIntra(intraMtx, std::defer_lock); std::unique_lock<std::mutex> lkInter(interMtx, std::defer_lock); std::lock(lkIntra, lkInter);

EDIT: I tried to compile this with gcc 4.3.X and 4.4.5. The linker was g ++ 4.3, 4.4, and 4.5.

EDIT2: I just tried using boost equivalents for std streams. After adding the "-lboost_thread" compiler flag, the compilation worked. Without which the binding process led to similar error messages. Now I'm wondering if I need to do something when using standard threads (I already tried "-lpthread").

+4
source share
1 answer

The current version of g ++ development supports it: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00729.html

Version 4.5.1 does not seem to be (at least for me on Intel Mac OS).

+1
source

Source: https://habr.com/ru/post/1332259/


All Articles