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.
Matt Godbolt is a C++ developer living in Chicago. Follow him on Mastodon or Bluesky.