semaphore:202:10: note: 'acquire' has been explicitly marked unavailable here [build] void acquire()

I use clang 12 to build some cpp project that needs semaphore.acquire() function.

System version: MacOs Big Sur 12.0

However, Compiler shows that some function is unavailable.

Detail messages:

/concurrencpp/source/executors/worker_thread_executor.cpp:42:21: error: 'acquire' is unavailable
[build]         m_semaphore.acquire();
[build]                     ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:202:10: note: 'acquire' has been explicitly marked unavailable here
[build]     void acquire()
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/worker_thread_executor.cpp:106:21: error: 'release' is unavailable
[build]         m_semaphore.release();
[build]                     ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:197:10: note: 'release' has been explicitly marked unavailable here
[build]     void release(ptrdiff_t __update = 1)
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/worker_thread_executor.cpp:121:21: error: 'release' is unavailable
[build]         m_semaphore.release();
[build]                     ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:197:10: note: 'release' has been explicitly marked unavailable here
[build]     void release(ptrdiff_t __update = 1)
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/worker_thread_executor.cpp:160:17: error: 'release' is unavailable
[build]     m_semaphore.release();
[build]                 ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:197:10: note: 'release' has been explicitly marked unavailable here
[build]     void release(ptrdiff_t __update = 1)
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/thread_pool_executor.cpp:218:26: error: 'try_acquire_until' is unavailable
[build]         if (!m_semaphore.try_acquire_until(deadline)) {
[build]                          ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:219:10: note: 'try_acquire_until' has been explicitly marked unavailable here
[build]     bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time)
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/thread_pool_executor.cpp:218:26: error: 'try_acquire_until<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1, 1000000000>>>' is unavailable
[build]         if (!m_semaphore.try_acquire_until(deadline)) {
[build]                          ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:219:10: note: 'try_acquire_until<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1, 1000000000>>>' has been explicitly marked unavailable here
[build]     bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time)
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/thread_pool_executor.cpp:322:25: error: 'release' is unavailable
[build]             m_semaphore.release();
[build]                         ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:197:10: note: 'release' has been explicitly marked unavailable here
[build]     void release(ptrdiff_t __update = 1)
[build]          ^
[build] /Users/mirocos/master/study/concurrencpp/source/executors/thread_pool_executor.cpp:420:17: error: 'release' is unavailable
[build]     m_semaphore.release();
[build]                 ^
[build] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/semaphore:197:10: note: 'release' has been explicitly marked unavailable here
[build]     void release(ptrdiff_t __update = 1)
[build]          ^
[build] 4 errors generated.

can anyone could help me with it?

Replies

Same problem here... Things I tried:

  • semaphore.max() works;
  • tried with try/catch;
  • I know I am using C++20;
  • Tried the sample code from the reference docs (https://en.cppreference.com/w/cpp/thread/counting_semaphore).

Out of ideas...

Add a Comment

Having the same issue

Updated XCode. Now it's ok.

add option -D_LIBCPP_DISABLE_AVAILABILITY