STL again...

Started by
5 comments, last by Halloween 22 years, 6 months ago
How to do such a simple thing like ... using namespace std; list< string > linkedListOfTheStrings; ... without compiler go bananas? And is it possible at all? Help me, please. Edited by - Halloween on September 26, 2001 10:29:48 AM
Advertisement
I believe this is what you are looking for

  #include <list>#include <string>// If you are using the VC++ compiler, you might have to // disable warning 4786 #pragma warning (disable:4786)string Message;list<string> ListOfStrings;ListOfStrings.push_back(Message);  


Alek
Thanks, man!
But what is the reason for compiler to cause such warning?..

Edited by - Halloween on September 26, 2001 10:30:26 AM
Read the compiler warning and it will tell you. Select the compiler warning and hit F1 and it will (usually) pop up a help page for that warning.
Yes, there is a commentary to the exception C4786 in the MSDN, though I could''t summon it simply by pressing F1.
It says compiler did truncate identifier due to its very long size. But it doesn''t say I can sleep calmly and be sure that by simple disabling that warning everything will be ok with my data structure. At least it is not obvious to me.
What it means (and I believe it says so in the documentation or warning) is that the debugger will be unable to resolve that variable at run-time because its name was truncated. The effect of this is that you can''t watch it. For this reason, I almost always explicitly dereference STL objects before I use them. If I have a vector of lists of strings (or something awful like that), instead of using an iterator directly (*it) I will do this:
string &str = *it;

This is "free" in that it compiles-out, and then you can look at the string in the debugger; you can''t look at "it" because it undoubtedly is longer than 4096 characters.
Thank you very much, Stoffel! There are a lot of things that cannon be learned simply through MSDN (I didn''t find that what you''ve said in the documentation I have), or at least it''s hard to figure out that without hours of scanning megs of information looking for a clue. So thanks again and thanks the God there are such forums

This topic is closed to new replies.

Advertisement