syntax error : missing ';' before '<'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • curious2007
    New Member
    • Jun 2007
    • 71

    #1

    syntax error : missing ';' before '<'

    in matrixsolvermec hanisms.hpp I have the following:

    [HTML]template <class V, class I> class LUTridiagonalSo lver

    { ...

    void calculateBetaGa mma();

    }[/HTML]
    Then in matrixsolvermec hanisms.cpp I have the following:

    [HTML]template <class V, class I> void LUTridiagonalSo lver<V,I>::calc ulateBetaGamma( ){
    ...}[/HTML]


    I am getting the following errors about this:

    syntax error : missing ';' before '<'
    'LUTridiagonalS olver' : illegal use of type 'void'
    unrecognizable template declaration/definition
    syntax error : '<'
    'calculateBetaG amma' : is not a member of '`global namespace''
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You are missing a semi-colon at the end of your class definition.

    I added it and the code compiled.

    Comment

    • curious2007
      New Member
      • Jun 2007
      • 71

      #3
      It seems like this is not the problem because I have ; in the original code. So, I don't understand how it compiles as I am using Visual C++ express as well. Might it be because I have some more code in these templates than the ones I have posted or is it because the definition and the decleration of functions are in seperate files in my code?

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by curious2007
        It seems like this is not the problem because I have ; in the original code. So, I don't understand how it compiles as I am using Visual C++ express as well. Might it be because I have some more code in these templates than the ones I have posted or is it because the definition and the decleration of functions are in seperate files in my code?
        Your compiler did not just spit out that error diagnostic text, it also gave you a
        file name and a line number. In your case just before that file and line number
        (probably in another .hpp or .h file) you have forgotten a trailing semi-colon.

        kind regards,

        Jos

        Comment

        • curious2007
          New Member
          • Jun 2007
          • 71

          #5
          what you say makes sense. However, I am having difficulty in identifying where that missing ";" is. The exact error message is as follows:

          1>main.cpp
          1>c:\users\ek\d ocuments\visual studio 2005\projects\v ec\vec\matrixso lvermechanisms. cpp(28) : error C2143: syntax error : missing ';' before '<'
          1>c:\users\ek\d ocuments\visual studio 2005\projects\v ec\vec\matrixso lvermechanisms. cpp(28) : error C2182: 'LUTridiagonalS olver' : illegal use of type 'void'
          1>c:\users\ek\d ocuments\visual studio 2005\projects\v ec\vec\matrixso lvermechanisms. cpp(28) : error C2988: unrecognizable template declaration/definition
          1>c:\users\ek\d ocuments\visual studio 2005\projects\v ec\vec\matrixso lvermechanisms. cpp(28) : error C2059: syntax error : '<'
          1>c:\users\ek\d ocuments\visual studio 2005\projects\v ec\vec\matrixso lvermechanisms. cpp(28) : error C2039: 'calculateBetaG amma' : is not a member of '`global namespace''

          So do you think the problem is in main.cpp or in matrixsolvermec hanisms.cpp?

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            This error:
            Originally posted by curious2007
            1>main.cpp
            1>c:\users\ek\d ocuments\visual studio 2005\projects\v ec\vec\matrixso lvermechanisms. cpp(2 8) : error C2143: syntax error : missing ';' before '<'
            says the compiler was compiling main.cpp and on line 28 it encountered an unexpected <. So it suggests you might are missing a ; on line 27, or 26, or 25, etc.

            You have to go backwards from the < on line 28 upwards in main.cpp and into the header files you included to see where the error is. It may not be a missing semi-colon. All you know for sure is that the compiler was not expecting a < on line 28.

            Fix the first error and recompile. Subsequent errors are often caused by the first error.

            Comment

            • curious2007
              New Member
              • Jun 2007
              • 71

              #7
              OK, I have found it it was before line 28 of matrixsolvermec hanisms.cpp.

              Comment

              Working...