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

Discussion in 'C++' started by Jeff, Mar 11, 2008.

  1. Jeff

    Jeff Guest

    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
    Jeff, Mar 11, 2008
    #1
    1. Advertising

  2. Re: error: expected `;' before 'itr' template compile error? Solarisvs Linux

    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
    Gianni Mariani, Mar 11, 2008
    #2
    1. Advertising

  3. Re: error: expected `;' before 'itr' template compile error? Solarisvs Linux

    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
    Gianni Mariani, Mar 11, 2008
    #3
  4. Jeff

    Jeff Guest

    Re: error: expected `;' before 'itr' template compile error? Solarisvs Linux

    On Mar 11, 1:25 pm, Gianni Mariani <> wrote:
    >
    > 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!
    Jeff, Mar 11, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page