Every time I debug with someone else at their machine, they are surprised by this little trick. So I will post it here.
In Windows programming, you often have Win32 calls which return an error, and you then need to call GetLastError() in order to find the real error number. If you are in the debugger, you don’t need to modify your code to call GetLastError at that point.
Instead, just add “@err” or “@err,hr” to your debug watch window. Now it’s more like looking at errno.
Nice trick, indeed!
Your post helped me to recall it after the 2 year period of non coding on Cpp
Was easier to google this answer here than in the official docs, hehe.
I would caution against the ,hr though, since GetLastError does not return an HRESULT. You want to copy the number and put it in the Tools->Error Lookup to see what it means.