468,469 Members | 2,080 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,469 developers. It's quick & easy.

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

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
3 3165
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
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
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.

Similar topics

5 posts views Thread by Enos Meroka | last post: by
1 post views Thread by Lionel van den Berg | last post: by
5 posts views Thread by cranium.2003 | last post: by
2 posts views Thread by etienne | last post: by
1 post views Thread by BSand0764 | last post: by
3 posts views Thread by Hill | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.