Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compiler failure in c++ 20 using the new semaphore library

Tags:

c++

linux

g++

c++20

c++20 introduced the library, however i'm unable to use it.

this is my compile line: g++-10 -std=c++20 sem.cpp -o sem

the error that I get is:

sem.cpp:4:10: fatal error: semaphore: No such file or directory
    4 | #include <semaphore>
      |          ^~~~~~~~~~~
compilation terminated.

I tried using a different compiler clang++ but it didn't make any difference.

Using Linux.

like image 290
pasta_coder Avatar asked Oct 11 '25 22:10

pasta_coder


1 Answers

GCC/libstdc++ 10 lacked support for this C++20 feature.

GCC 11 (released April 2021) provides the semaphore header file as do recent versions of Clang and MSVC.

https://en.cppreference.com/w/cpp/compiler_support

like image 173
PFee Avatar answered Oct 14 '25 11:10

PFee