![](/img/trans.png)
[英]How do I use `std::error_category` and the other stuff that is in the system_error header?
[英]How do you use std::system_error with GetLastError?
请注意,比较std::system_category()
类别中的std::error_code
通常不会使用std::errc
枚举常量,具体取决于您的供应商。 例如
std::error_code(ERROR_FILE_NOT_FOUND, std::system_category()) != std::errc::no_such_file_or_directory)
某些供应商需要使用std::generic_category()
才能工作。
在MinGW std::error_code(ERROR_FILE_NOT_FOUND, std::system_category()).message()
不会给你正确的消息。
对于一个真正可移植且强大的解决方案,我建议将std::system_error
和std::system_category
子类std::system_category
windows_error
和windows_category
并自己实现正确的功能。 据报道,YMMV,VS2017正如人们所期望的那样工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.