-
MSVC++ error query
This function:
Code:
vector<string> split (const string& s) // function that splits a string and inserts the individual
{ // words into a vector<string>
vector<string> ret;
typedef string::size_type string_size;
string_size i = 0;
while (i != s.size())
{
while (i != s.size() && isspace(s[i])) // finds the first non-space char - will be at position i
i++;
string_size j = i;
while (j != s.size() && !isspace(s[j])) // finds the first space character after i - will be at position j
j++;
if (i != j) // if any words have been found
{
ret.push_back(s.substr(i, j-i)); // pushes back the word found between i and j
i = j;
}
}
return ret;
works fine under code-warrior, but i get the following warning when compiling with MSVC:
C:\Program Files\Microsoft Visual Studio\MyProjects\test\test.cpp(38) : 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>,st d::allocator<c
har> >,std::basic_string<char,std::char_traits<char>,st d::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,st d::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
Why?
-
because MSVC only uses identifiers up to 255 characters long. When using templates it's quite easy to generate long identifiers so you've gone over this limit. It's telling you that it'll only use the first 255 characters as a debugging symbol. You can't solve the underlying problem (it won't affect how the code executes), but you can suppress the warning messages by placing -
#pragma warning (disable:4786)
before you inlcude the headers.
-
Thanks for the info. Sorensen.