Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

c - Expected identifier or something?

I have typed code posted below in DEV C++, which is an updated version, the Orwell one. It gave me some errors and I would like you to help me with them :) Most of the errors are already been fixed by me, but some of them I just cant explain. I am just trying to do simple MS app program.

Compiler gives me this error:

LINE 53 [Error] expected identifier or '(' before '{' token

The code:

# include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WinMain (HINSTANCE hinstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {

        static TCHAR szAppName[] = TEXT ("HelloWin");
        HWND                    hwnd;
        MSG                     msg;
        WNDCLASS                wndclass;
        wndclass.style         = CS_HREDRAW| CS_VREDRAW;
        wndclass.lpfnWndProc   = WndProc;
        wndclass.cbClsExtra    = 0;
        wndclass.cbWndExtra    = 0;
        wndclass.hInstance     = hinstance;
        wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
        wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW);
        wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
        wndclass.lpszMenuName  = NULL;
        wndclass.lpszClassName = szAppName;

        if (!RegisterClass (&wndclass))
        {
            MessageBox (NULL, TEXT ("XXCXCXCXCX"), szAppName, MB_ICONERROR);
            return     (0);
         }     

        hwnd  = CreateWindow    (szAppName,
                                TEXT("FRFRFRFRF"),
                                WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                NULL,
                                NULL,
                                hinstance,
                                NULL);
        ShowWindow  (hwnd, iCmdShow);
        UpdateWindow (hwnd);

        while (GetMessage (&msg, NULL, 0, 0))
            {
                TranslateMessage (& msg);
                DispatchMessage  (& msg);
            }   /* END while*/
            return (msg.wParam);

    }           /* END WinMain () */


LRESULT CALLBACK WndProc(HWND, UINT message, WPARAM wParam, LPARAM lparam);
  { ("**this is line 53**")




                HDC                   hdc;
                PAINTSTRUCT           ps;
                RECT                  rect;


                switch (message)

                {

                    case        WM_CREATE:
                                PlaySound("FRFRFRZZZZZ.wav"), NULL, SND_FILENAME|SND-ASIAC
                                return (0);

                    case        WM_PAINT:
                                hdc = BeginPaint (hwnd, &ps);
                                GetClientRect (hwnd, &rect);
                                DrawText (hdc, TEXT ("HZHZHZHZ!"), -1, &, DT_SINGLELINE|DT-CENTER|DT_VCENT;
                                EndPoint (hwnd, &ps);
                                return (0);

                    case        WM_DESTROY;
                                PostQuitMessage (0);
                                return (0);

                }  

                return      (DefWindowProc (hwnd, message, wParam, lParam));

    }        

Happy new year, and it's the rest of the code okay?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Delete the semicolon ; at:

LRESULT CALLBACK WndProc(HWND, UINT message, WPARAM wParam, LPARAM lparam);

Edited For clarity.

You have a declaration at the beginning that looks like the following

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); // <-- OK

Later you have the actual function

LRESULT CALLBACK WndProc(HWND, UINT message, WPARAM wParam, LPARAM lparam); // <--Error. Delete ';'
{ ("**this is line 53**")
:
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...