P
pplppp
Hi,
I have a simple program which I wrote and compiled on SCO Unixware
7.1.1 (compiler is CC) with SGI STL and it compiled and worked fine.
Now I'm using GNU GCC 4.0.0 on linux, with the GCC implementation of
STL and I have some trouble trying compile the same code:
the following is a segemnt of my program:
[StringUtil.h]
....
#include <string>
using namespace std;
....
template<typename T>basic_string<T> trimCopy(const basic_string<T>&
str);
....
[StringUtil.cpp]
....
template<typename T>basic_string<T> trimCopy(const basic_string<T>&
str)
{
basic_string<T>::size_type front = str.find_first_not_of(" \t\n");
// line 97
basic_string<T>::size_type end = str.find_last_not_of(" \t\n"); //
line 98
return str.substr(front, end-front+1); // line 99
}
....
when I try to compile the program, g++ gives me an error
/usr/local/bin/g++ -g -frepo -O -I. -I/usr/local/include -c
StringUtil.cpp
StringUtil.cpp: In function 'std::basic_string<T,
StringUtil.cpp:98: error: expected `;' before 'end'
StringUtil.cpp:99: error: 'front' was not declared in this scope
StringUtil.cpp:99: error: 'end' was not declared in this scope
I would like to know why I'm getting this error, since with the SGI STL
implementation and SCO Unixware CC compiler I have no problem with the
same piece of code. Any help is appreciated
Thanks in advance
newbie
I have a simple program which I wrote and compiled on SCO Unixware
7.1.1 (compiler is CC) with SGI STL and it compiled and worked fine.
Now I'm using GNU GCC 4.0.0 on linux, with the GCC implementation of
STL and I have some trouble trying compile the same code:
the following is a segemnt of my program:
[StringUtil.h]
....
#include <string>
using namespace std;
....
template<typename T>basic_string<T> trimCopy(const basic_string<T>&
str);
....
[StringUtil.cpp]
....
template<typename T>basic_string<T> trimCopy(const basic_string<T>&
str)
{
basic_string<T>::size_type front = str.find_first_not_of(" \t\n");
// line 97
basic_string<T>::size_type end = str.find_last_not_of(" \t\n"); //
line 98
return str.substr(front, end-front+1); // line 99
}
....
when I try to compile the program, g++ gives me an error
/usr/local/bin/g++ -g -frepo -O -I. -I/usr/local/include -c
StringUtil.cpp
StringUtil.cpp: In function 'std::basic_string<T,
StringUtil.cpp:97: error: expected `;' before 'front'std::allocator<_CharT> > trimCopy(const said:&)':
StringUtil.cpp:98: error: expected `;' before 'end'
StringUtil.cpp:99: error: 'front' was not declared in this scope
StringUtil.cpp:99: error: 'end' was not declared in this scope
I would like to know why I'm getting this error, since with the SGI STL
implementation and SCO Unixware CC compiler I have no problem with the
same piece of code. Any help is appreciated
Thanks in advance
newbie