I have some kinda problem each time i create a vector of strings. There is no error if I create vectors of other data types such as int, double, etc. Though there's no error...but there's warnings...and sometimes the program hangs if i do sortings. Here's an (without sorting but still getting warnings) example:

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
vector<string> values(5);
values.push_back("dog");
values.push_back("cat");
values.push_back("bag");
values.push_back("box");
values.push_back("boy");

for(int i = 0; i < values.size(); i++ )
{
cout << values[i] << " ";
}

return 0;
}

This is the message in the build tab:

Compiling...
testSortString.cpp
C:\Documents and Settings\Jason\Desktop\testSortString\testSortString.cpp(24) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::all
ocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
C:\Documents and Settings\Jason\Desktop\testSortString\testSortString.cpp(24) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator
<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
i:\microsoft visual studio\vc98\include\vector(47) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::vector<std
::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
i:\microsoft visual studio\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~vector<st
d::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information

testSortString.exe - 0 error(s), 4 warning(s)

Hope you guys enlighten me....thanks in advance....

4
Contributors
8
Replies
9
Views
11 Years
Discussion Span
Last Post by borlys

You must be using visual studio 6. You can disable the warning with a pragma statement.

DEV C++ doesn't give these warnings.....but what does these warning signify??

You must be using visual studio 6. You can disable the warning with a pragma statement.

Yup, I'm using visual studio 6.0. Just downloaded the service pack 6. Browsed through the error listing in MSDN, where they show some errors solved by including pragma statements. But in their example is something to do with indentifiers being too long. Guess I need to learn how to use pragma statements in my c++.
Anyway, thanks for the reply and help. :cheesy:

DEV C++ doesn't give these warnings.....but what does these warning signify??

Ooops, one thing I missed in the posting. I'm using Visual Studio 6.0. Sorry guyz. Thanks for replying though.. :)

But in their example is something to do with indentifiers being too long. :cheesy:

Yes, there is an issue with vs 6 where it complains about templates that generate identifiers longer than 246 characters. I think you simply put:
#pragma warning(disable: 4786) at the top of code. See #4 here: http://www.mip.sdu.dk/ipl98/unofficial/visualc/tips_and_tricks.htm

Yes, there is an issue with vs 6 where it complains about templates that generate identifiers longer than 246 characters. I think you simply put:
#pragma warning(disable: 4786) at the top of code. See #4 here: http://www.mip.sdu.dk/ipl98/unofficial/visualc/tips_and_tricks.htm

Yeah, found that out today....that I need to put the

#pragma warning(disable: 4786)

before include statements that are usually declared at the top.
I wonder if that still happens if I install the latest service pack 6....I'll check it out then.

Anyway...thanks to you guyz for being so helpful. This is the best forum I've ever been in......guyz/gals in here just know their stuff....beats having bad lecturers in college. Daniweb and MSDN is the best guide! :mrgreen:

I don't think the service pack helps. I know that later versions of Visual Studio (2003), etc. do not have this problem.

I have some kinda problem each time i create a vector of strings. There is no error if I create vectors of other data types such as int, double, etc. Though there's no error...but there's warnings...and sometimes the program hangs if i do sortings. Here's an (without sorting but still getting warnings) example:

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
vector<string> values(5);
values.push_back("dog");
values.push_back("cat");
values.push_back("bag");
values.push_back("box");
values.push_back("boy");

for(int i = 0; i < values.size(); i++ )
{
cout << values[i] << " ";
}

return 0;
}

This is the message in the build tab:

Compiling...
testSortString.cpp
C:\Documents and Settings\Jason\Desktop\testSortString\testSortString.cpp(24) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::all
ocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
C:\Documents and Settings\Jason\Desktop\testSortString\testSortString.cpp(24) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator
<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
i:\microsoft visual studio\vc98\include\vector(47) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::vector<std
::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
i:\microsoft visual studio\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~vector<st
d::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information

testSortString.exe - 0 error(s), 4 warning(s)

Hope you guys enlighten me....thanks in advance....

Just small remark about the code given above:
As a result of the declaration you obtain an array of 5 strings, which are undefined. The following lines of code (with push_back methods) push back :)) the NEW elements of array. Summarizing,
you obtain an array of 10 elements where the first five are undefined and the last five are dog, cat, ...

With best wishes,
Borys

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.