Auto-Expanding User-Defined (and STL) Types in the Debugger | CodeGuru

Auto-Expanding User-Defined (and STL) Types in the Debugger

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Mar 14, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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
std::basic_string<char,std::char_traits<char>,std::allocator<char>> =<_Ptr,s>

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<. I
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
following (untested):

std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> =<_Ptr,su>

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.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.