Quick_exit () is not available

I tried to use some stream codes, and I used the quick_exit function to end the program without clearing the resource, below is my code.

#include<future> #include<iostream> #include<thread> // std::thread, std::this_thread::sleep_for #include<chrono> #include<cstdlib> using namespace std; static void pause_thread(int n) { std::this_thread::sleep_for (std::chrono::seconds(n)); std::cout << "pause of " << n << " seconds ended\n"; } int main() { std::cout << "Spawning and detaching 3 threads...\n"; std::thread (pause_thread,5).detach(); std::thread (pause_thread,8).detach(); std::thread (pause_thread,9).detach(); std::cout << "Done spawning threads.\n"; std::cout << "(the main thread will now pause for 2 seconds)\n"; // give the detached threads time to finish (but not guaranteed!): pause_thread(2); quick_exit(0); //here is the problem,was this a problem? return 0; } 

compilation using gcc 5.3.0 and the command i used

g++ -std=c++11 pracrise.cpp -lpthread

stream model: posix

I am missing nothing that I opened the cstdlib header file there quick_exit .

 C:\Program Files\mingw64>g++ -std=c++11 pracrise.cpp -lpthread pracrise.cpp: In function 'int main()': pracrise.cpp:25:15: error: 'quick_exit' was not declared in this scope quick_exit(0); ^ 
+5
source share

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


All Articles