Have you ever wondered why CStrings, CPoints, and CRects always display
their contents in the debugger, while std::strings and your own data
types don’t? I have, especially since I’ve started using the Standard
Library. I find it especially annoying to click on the little plus sign
to view the contents of a std::string object.
In Visual C++ 5 (and probably 6, although I don’t have it to test), there
is an undocumented feature that controls this display (called
auto-expansion). It is controlled by a file named AutoExp.DAT in the
DevStudioSharedIDEBin directory. That file is pretty much
self-documenting. An excerpt from the file reads:
“While debugging, Data Tips and items in the Watch and Variable windows
are automatically expanded to show their most important elements. The
expansion follows the format given by the rules in this file. You can add
rules for your types or change the predefined rules.”
To resolve my frustration with std::string, I simply added the following
lines in the [AutoExpand] section of the file:
; from string
Note that the spacing (or lack thereof) is important. Also note that I
was not able to use just std::string or std::basic_string<
needed to use the fully expanded type, including all template parameters.
If you use Unicode and std::wstring, you’ll need an entry such as the
You’ll also need to change the DisplayUnicode setting to 1 in the
[Unicode] section of the file so that Unicode strings are automatically
expanded as text, rather than arrays of unsigned short.