c++ - error_code vs errno -


i studying c++11 standards. wanted understand if error_code , errno related each other? if yes how? if no in conditions should expect errno set , in conditions error_code set?

i did small test program understand still little confused. please help.

#include <iostream> #include <system_error> #include <thread> #include <cstring> #include <cerrno> #include <cstdio>  using namespace std;  int main() {     try     {         thread().detach();     } catch (const system_error & e) {         cout<<"error code value - "<<e.code().value()<<" ; meaning - "<<e.what()<<endl;         cout<<"error no. - "<<errno<<" ; meaning - "<<strerror(errno)<<endl;     } }  output - error code value - 22 ; meaning - invalid argument error no. - 0 ; meaning - success 

errno used functions document side effect of encountering error - functions c library or os functions never throw exceptions. system_error used c++ standard library when you're using library facilities documented throw exception. separate. ultimately, read docs!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -