This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler error

The following code gives

error #66: expected a ";"

using Code Composer Studio Version: 5.5.0.00077

It seems OK to me.  Visual Studio seemed OK with it.

 

#include <vector>

template <typename T>

class Foo

{

    void func() const

    {

        std::vector<T>::const_iterator i;  // error here

    }

};

int main()

{

    Foo<int> f;

    return 0;

}

 

Am I missing a problem with the code or is this a limitation in the compiler?

  • Make sure to name your file with the extension .cpp, or the compiler will treat it as a C file.

    What version of the compiler are you using?  (This is different than the CCS version)

  • Thank you for the reply.

    I have verified that the file extension is .cpp.

    The compiler version is: TI v7.4.5.

  • My C++ knowledge might have been in error.

    I tried the code in gcc to see what it thought, and it gave me the following:

    main.cpp:8:9: error: need `typename' before `std::vector<T>::const_iterator' because `std::vector<T>' is a dependent scope

    main.cpp:8:40: error: expected `;' before `i'

    I then added typename to the indicated line and it compiled OK on gcc, TI, and VS.  Here is the updated code:

    #include <vector>

    template <typename T> class Foo

    {

        void func() const

        {

            typename std::vector<T>::const_iterator i;

        }

    };

    int main()

    {

        Foo<int> f;

        return 0;

    }

     

    Thank you all for your assistance.