Compiler Error Help please

This is a discussion on Compiler Error Help please within the C++ Programming forums, part of the General Programming Boards category; I have a feeling it's something extreeeeeemely simple, but I am just basically copying and pasting from a websource. Here's ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    102

    Wink Compiler Error Help please

    I have a feeling it's something extreeeeeemely simple, but I am just basically copying and pasting from a websource. Here's the error:

    In file included from WinMain.cpp:3:
    Resrouce.rc:3: error: expected unqualified-id before numeric constant
    Resrouce.rc:3: error: expected `,' or `;' before numeric constant

    make.exe: *** [WinMain.o] Error 1

    Execution terminated

    Heres the code:

    WinMain
    Code:
    #include <windows.h>
    #include "Resource.h"
    #include "Resrouce.rc"
    
    const char WinClassName[] = "myWindowClass";
    
    // Step 4: the Window Procedure
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        switch(msg)
        {
            case WM_CLOSE:
                DestroyWindow(hwnd);
                break;
            
            case WM_LBUTTONDOWN:
                {
                char szFileName[MAX_PATH];
                HINSTANCE hInstance = GetModuleHandle(NULL);
    
                GetModuleFileName(hInstance, szFileName, MAX_PATH);
                MessageBox(hwnd, szFileName, "This program is:", MB_OK | MB_ICONINFORMATION);
    
                break;
                }
            case WM_DESTROY:
                PostQuitMessage(0);
                break;
            
            default:
                return DefWindowProc(hwnd, msg, wParam, lParam);
        }
        return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR lpCmdLine, int nCmdShow)
    {
        WNDCLASSEX wc;
        HWND hwnd;
        MSG Msg;
    
        //Step 1: Registering the Window Class
        wc.cbSize        = sizeof(WNDCLASSEX);
        wc.style         = 0;
        wc.lpfnWndProc   = WndProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = hInstance;
        wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
        wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);;
        wc.lpszClassName = WinClassName;
        wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
        if(!RegisterClassEx(&wc))
        {
            MessageBox(NULL, "Window Registration Failed!", "Error!",
                MB_ICONEXCLAMATION | MB_OK);
            return 0;
        }
    
        // Step 2: Creating the Window
        hwnd = CreateWindowEx(
            WS_EX_CLIENTEDGE,
            WinClassName,
            "The title of my window",
            WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
            NULL, NULL, hInstance, NULL);
    
        if(hwnd == NULL)
        {
            MessageBox(NULL, "Window Creation Failed!", "Error!",
                MB_ICONEXCLAMATION | MB_OK);
            return 0;
        }
    
        ShowWindow(hwnd, nCmdShow);
        UpdateWindow(hwnd);
    
        // Step 3: The Message Loop
        while(GetMessage(&Msg, NULL, 0, 0) > 0)
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
        return Msg.wParam;
    }
    Resource.h

    Code:
    /* Resource.h  */
    
    #define IDR_MYMENU 101
    
    #define ID_FILE_EXIT 9001
    #define ID_STUFF_GO 9002
    Resource.rc
    Code:
    #include "Resource.h"
    
    IDR_MYMENU MENU
    {
        POPUP "&File"
        {
            MENUITEM "E&xit", ID_FILE_EXIT
        }
    
        POPUP "&Stuff"
        {
            MENUITEM "&Go", ID_STUFF_GO
            MENUITEM "G&o somewhere else", 0, GRAYED
        }   
        
    }
    If anyone could please let me know this error, I havent used any resources prior to this in my compiler(Dev C++). That is why I came straight here instead of searching elsewhere..
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,252
    You can't #include a .rc file... I only know enough about Windows to know that that's wrong

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    102
    Ok.. thanks, I actualy thought that first lol, however I get another error when I don't include it.

    gcc: installation problem, cannot exec `cc1': No such file or directory

    windres.exe: no resources

    make.exe: *** [Windows_private.res] Error 1

    Execution terminated
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    5
    Hey! i recognise that code by any chance are you doing the forgers win32 API programming tutorial?

    try putting those #define's at the top of ur resource file and cpp file and getting rid of the header, that worked for me!

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Try something like....

    Code:
    windres Resource.rc resource.o
    g++ whatever.cpp resource.o
    Both the .rc and the .cpp files must include Resource.h

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    102
    Hmm. Not sure I understand you exactly McGyver, and thanks for your replies all.

    Where should I put?
    windres Resource.rc resource.o
    g++ whatever.cpp resource.o

    In the header file?
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

  7. #7
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    I was referring to manually compiling the project.

  8. #8
    Registered User
    Join Date
    Apr 2007
    Posts
    102
    Ah got you, I'll try it out.. Thanks.
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

  9. #9
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Code:
    #include "Resrouce.rc"
    It would appear that you've mis-spelled this line (although, as someone else pointed out, you probably shouldn't be using #include on a resource file anyway)

  10. #10
    Registered User
    Join Date
    Apr 2007
    Posts
    102
    Lol yes, thanks i really need to look those things over.. To tell you the truth resrouce is the name of the file lol, I accidently saved it wrong :/ So it is indeed correctly including the file. However without the file Included I get a different error. ^ Read up ^
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  3. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  4. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 05:42 AM
  5. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 10:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21