Vector of strings (warnings) ? ?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2005
Posts: 42
Reputation: j1979c is an unknown quantity at this point 
Solved Threads: 0
j1979c's Avatar
j1979c j1979c is offline Offline
Light Poster

Vector of strings (warnings) ? ?

 
0
  #1
Nov 6th, 2005
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:

  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. vector<string> values(5);
  9. values.push_back("dog");
  10. values.push_back("cat");
  11. values.push_back("bag");
  12. values.push_back("box");
  13. values.push_back("boy");
  14.  
  15. for(int i = 0; i < values.size(); i++ )
  16. {
  17. cout << values[i] << " ";
  18. }
  19.  
  20. return 0;
  21. }

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
Linking...

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

Hope you guys enlighten me....thanks in advance....
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Vector of strings (warnings) ? ?

 
0
  #2
Nov 6th, 2005
You must be using visual studio 6. You can disable the warning with a pragma statement.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: Vector of strings (warnings) ? ?

 
0
  #3
Nov 6th, 2005
DEV C++ doesn't give these warnings.....but what does these warning signify??
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 42
Reputation: j1979c is an unknown quantity at this point 
Solved Threads: 0
j1979c's Avatar
j1979c j1979c is offline Offline
Light Poster

Re: Vector of strings (warnings) ? ?

 
0
  #4
Nov 7th, 2005
Originally Posted by winbatch
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:
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 42
Reputation: j1979c is an unknown quantity at this point 
Solved Threads: 0
j1979c's Avatar
j1979c j1979c is offline Offline
Light Poster

Re: Vector of strings (warnings) ? ?

 
0
  #5
Nov 7th, 2005
Originally Posted by sunnypalsingh
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..
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Vector of strings (warnings) ? ?

 
0
  #6
Nov 7th, 2005
Originally Posted by j1979c
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/unoffici...and_tricks.htm
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 42
Reputation: j1979c is an unknown quantity at this point 
Solved Threads: 0
j1979c's Avatar
j1979c j1979c is offline Offline
Light Poster

Re: Vector of strings (warnings) ? ?

 
0
  #7
Nov 7th, 2005
Originally Posted by winbatch
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/unoffici...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:
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Vector of strings (warnings) ? ?

 
0
  #8
Nov 7th, 2005
I don't think the service pack helps. I know that later versions of Visual Studio (2003), etc. do not have this problem.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC