Things I didn't know about Visual Studio's Debugger

I’ve used Visual Studio in its various incarnations since version 5.0, and I’m still finding cool little things out about it. Today, while Googling about for debugger-related things, I stumbled across a CodeProject post which contains a real gem. It’s possible to create a watch on the value of GetLastError() — the pseudovariable @ERR reflects the value of the last error generated.

Additionally, the format specifier hr formats the number as an HRESULT style identifier, so putting @ERR, hr in a watch pane shows values like S_OK. Previously I’ve only known about the number formats (e.g. 12 to show 12 elements of an array) and x to show stuff in hex.

Dead handy stuff, and worth checking out the original article for even more pseudovariables.

Filed under: Coding
Posted at 17:42:00 GMT on 18th February 2008.

About Matt Godbolt

Matt Godbolt is a C++ developer working in Chicago for Aquatic. Follow him on Mastodon.