Why is std::string constructor resetting GetLastError

前端 未结 3 1481
走了就别回头了
走了就别回头了 2021-01-13 17:26

I\'m calling Windows APIs from C++ code and I have a helper method to do the FormatMessage stuff and throw an exception for error handling. The signature of the

3条回答
  •  心在旅途
    2021-01-13 17:56

    This is normal - the "last error" can be set indirectly through any function call.
    Some functions set it to "no error" on success, so if you want to use it reliably you need to store it immediately before you do anything else.

    If you've ever encountered an "A serious error occurred: The operation completed successfully" dialogue, this is probably the reason.

提交回复
热议问题