Say I have the following
int num = 40 + str2Int("30");
Is there anyway with visual studio 2008 to tell what Str2Int is returning without stepping into the function and going to the return?
View return values for functions If the window is closed, use Debug > Windows > Autos to open the Autos window. In addition, you can enter functions in the Immediate window to view return values. (Open it using Debug > Windows > Immediate.)
The return value of a command is stored in the $? variable. cmd; echo $?; The return value is called exit status. This value can be used to determine whether a command completed successfully or unsuccessfully.
In C++, a function which is defined as having a return type of void , or is a constructor or destructor, must not return a value. If a function is defined as having a return type other than void , it should return a value.
Right-click a variable or expression that you want to watch and choose Add Inline Watch in the context menu. An inline watch will be created for that variable or expression.
In the "auto" variable windows it will display the result of any operations you just stepped over.
Edit: Removed uncertainty over the location of this (thanks goes to Michael Burr)
Since the return value is generally in the EAX register, you put the $eax
'variable' in the watch window. When you step over the function call, what's in EAX is what that function returned.
And if you also provide the hr
format symbol the debugger will show you the HRESULT or Win32 error message (like "S_OK" or "Access is denied") instead of just the raw number. It can be handy to have each ($eax
and $eax,hr
) in separate watch entries.
Another useful entry is $err
which shows whatever GetLastError()
would return (and the hr
format symbol can be applied to it - or anything - as well):
$eax
$eax,hr
$err
$err,hr
Note that older versions of the VS debugger might want you to use a @
instead of a $
to start these variables, but a member of the debugger team has stated that $
is preferred to keep things in line with the "Debugging Tools for Windows" toolset (I think that support for @
is deprecated and might be removed at some point).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With