By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,979 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,979 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Mar 11 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jeff wrote:
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.
<---- 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
Mar 11 '08 #2

P: n/a
Jeff wrote:
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.
<---- 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
Mar 11 '08 #3

P: n/a
On Mar 11, 1:25 pm, Gianni Mariani <gi4nos...@mariani.wswrote:
>
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!
Mar 11 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.