error: expected `;' before 'itr' template compile error? Solaris vsLinux

J

Jeff

Im compiling code on Fedora and I get the following error:

202: error: expected `;' before 'itr'

this is in a .h file which has no .cpp file:

template < typename Tcharl, typename Tcharr >
inline std::basic_string<Tcharl>& CR_String::StrCpy
( std::basic_string<Tcharl> &dest, const std::basic_string<Tcharr>
&src )
{
std::basic_string<Tcharr>::const_iterator itr = src.begin();
<---- line 202

while ( itr != src.end() )
{
dest.append( 1, Tcharl(*itr) );
itr++;
}
return dest;
}

Compile flags: -Wall -g

Compiler g++ version 4.0.0

Ive compiled this same code on Solaris 10 and Windows 2003 just fine.
It seems to be having issues with Tcharr because if I change it to an
int,
its fine, however I havent been able to figure out how to properly fix
it
for Linux and why its occuring only on Linux and not Solaris or
Windows?

Thanks in advance
 
G

Gianni Mariani

Jeff said:
Im compiling code on Fedora and I get the following error:

202: error: expected `;' before 'itr'

this is in a .h file which has no .cpp file:

template < typename Tcharl, typename Tcharr >
inline std::basic_string<Tcharl>& CR_String::StrCpy
( std::basic_string<Tcharl> &dest, const std::basic_string<Tcharr>
&src )
{
std::basic_string<Tcharr>::const_iterator itr = src.begin();

Prepend "typename"... i.e.
typenaame std::basic_string<Tcharr>::const_iterator itr = src.begin();

The FAQ I'm sure covers the use of typename - otherwise a google groups
search will also give you and answer.
 
G

Gianni Mariani

Jeff said:
Im compiling code on Fedora and I get the following error:

202: error: expected `;' before 'itr'

this is in a .h file which has no .cpp file:

template < typename Tcharl, typename Tcharr >
inline std::basic_string<Tcharl>& CR_String::StrCpy
( std::basic_string<Tcharl> &dest, const std::basic_string<Tcharr>
&src )
{
std::basic_string<Tcharr>::const_iterator itr = src.begin();

Prepend "typename"... i.e.
typenaame std::basic_string<Tcharr>::const_iterator itr = src.begin();

The FAQ I'm sure covers the use of typename - otherwise a google groups
search will also give you and answer.
 
J

Jeff

Prepend "typename"... i.e.
typenaame std::basic_string<Tcharr>::const_iterator itr = src.begin();

The FAQ I'm sure covers the use of typename - otherwise a google groups

Thanks, that fixed it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top