none
error C2143: syntax error : missing ';' before '*'

    Question

  • The line of code which is causing this error is:-

     

    CD3DVertexCache *m_pVertexCache;

     

    CD3DVertexCache is a class.  Usually this is a stupid error meaning I've not included the header file for the class.  However on this occasion I have included the header file for the class.  Further more when I run the mouse cursor over the class name the little message box appears class CD3DVertexCache.  Which tells me the compiler knows of the class identifier.  I'm not sure why I'm getting the error message, wondering if someone can advise what other situations would cause this error to appear?

     

    Thanks,

     

    Paul.

    Friday, May 02, 2008 10:11 PM

Answers

  •  

    Usually means that there is an error or omission in the previous line(s).

    Check for a missing semi-colon or other error(s) in the line(s) immediately

    *before* the one indicated by the error message.

     

    Check also for a missing semi-colon at the end of class and structure definitions.

     

    - Wayne

     

     

    Friday, May 02, 2008 11:25 PM

All replies

  •  

    Usually means that there is an error or omission in the previous line(s).

    Check for a missing semi-colon or other error(s) in the line(s) immediately

    *before* the one indicated by the error message.

     

    Check also for a missing semi-colon at the end of class and structure definitions.

     

    - Wayne

     

     

    Friday, May 02, 2008 11:25 PM
  • I figured out why it doesn't work in visual studio c++. Here is the correct code I used to fix my error C2143:

    #include "Wave.h" /* This header file has the CWave class in it */

    CWave *wave1;

    int main()
    {
        wave1.Load(_T("C:...\Music.wav"));
        wave1.Play();
        Sleep(100000);
    }
    Thursday, June 23, 2011 2:54 PM
  • On 23/06/2011 16:54, Espada7Zommari wrote:
    > I figured out why it doesn't work in visual studio c++. Here is the
    > correct code I used to fix my error C2143:
    >
    > #include "Wave.h" /* This header file has the CWave class in it */
    >
    > CWave *wave1;
    >
    > int main()
    > {
    > wave1.Load(_T("C:...\Music.wav"));
    > wave1.Play();
     
    Considering that wave1 is a pointer to an instance of CWave, correct
    code should be wave1->Load(...), wave1->Play(...), ...
     
    Giovanni
     
    Thursday, June 23, 2011 3:34 PM
  • This error may also be caused when a define many classes in a single file. When we want to make use of the class written at lower portion of the file in the upper portion. The upper not know of class declaration so produces this error.

    example: File Name "ABC.h"

    ClassA

    {

    };

    ClassB

    {

    ClassA* ClassB::DoIT() // its ok

    {

      ClassA* PA=NULL;

        return PA;

    }

    ClassC* ClassB::DoIT() // Complier error C2143 because ClassC unknown at this point

    {

      ClassC* pC = NULL;

        return pC;

    }


    };

    ClassC

    {

    };

    Wednesday, April 25, 2012 9:25 AM