devxlogo

Compiler Warnings with STL Map Containers

Compiler Warnings with STL Map Containers

Question:

Using even the most basic default constructor, such as ” mapm; ” , causes a debug error creating huge compiler warnings in Visual C++ and MS Visual Studio 6.0. That one line alone causes 6 warnings and the small sample program below ultimately creates a total of 19 warnings. The code executes without further incident but the unresolved warnings trouble me. In essence, the compiler warnings indicate that the debugger continues to append class names into long command lines that eventually exceed the 255-character limitation. The suggested resolution, substituting a 1-character name for the class name during debug time, does not work. Is there a fix?

#include #include #include using namespace std;class classic  {	 long account;	 char descrip[50];  public:	 classic (); 	 classic (int yr, char *who_or_what);	~classic (); 	 void show_list (); 	 int  get_val () const;	 bool target (int low, int hi);	 friend ostream &operator= low && account  (const classic &item1, const classic &item2)  {	return item1.get_val() > item2.get_val();}bool operator== (const classic &item1, const classic &item2)  {	return item1.get_val() == item2.get_val();}bool operator!= (const classic &item1, const classic &item2)  {	return item1.get_val() != item2.get_val();}// --------------------------//int main(){		int accts = 0;	cout  line;		//  Fill the map	line.insert( pair( long(10000), classic(10000, "Sandal Accounts")) );	line.insert( pair( long(10500), classic(10500, "Slipper Accounts")) );	line.insert( pair( long(21000), classic(21000, "Women's Shoe Accounts")) );	line.insert( pair( long(31000), classic(31000, "Men's Shoe Accounts")) );	line.insert( pair( long(50500), classic(50500, "Boot Accounts")) );		//  Display map data	map::iterator p;	accts = line.size();	cout  second.show_list();	cout  second.show_list();	cout  second.show_list();		p++;	}	return 0;}

Answer:

You shouldn’t pick very short names for your identifiers, this isn’t the cause of your problem, and therefore, it will not hush these warnings. These warnings result from a debugger shortcoming, which will be fixed in the next Visual C++ release, hopefully. As always, use meaningful names for identifiers.

This warning message occurs frequently when using templates, and STL containers in particular. Essentially, it says that the debugger cannot display the symbolic names of the functions in the template classes because they exceed the 255 character limit. You can safely ignore this warning. When you build a release version of your app, these warnings will disappear.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist