Thread: New buggy problem

  1. #1
    using namespace Trooper; St0rmTroop3er's Avatar
    Join Date
    Sep 2003
    Posts
    77

    New buggy problem

    what does this error mean?

    Code:
    G3D_P1.cpp:33:19: fcnt1.h: No such file or directory
    G3D_P1.cpp: In function `LRESULT WindowProc(HWND__*, unsigned int, unsigned 
       int, long int)':
    G3D_P1.cpp:57: case label `15' not within a switch statement
    G3D_P1.cpp:68: case label `2' not within a switch statement
    G3D_P1.cpp:77: `default' label not within a switch statement
    
    G3D_P1.cpp:55: break statement not within loop or switch
    G3D_P1.cpp:66: break statement not within loop or switch
    G3D_P1.cpp:75: break statement not within loop or switch
    G3D_P1.cpp:77: break statement not within loop or switch
    G3D_P1.cpp: At global scope:
    G3D_P1.cpp:82: parse error before `return'
    
    G3D_P1.cpp:153: parse error before `return'
    
    G3D_P1.cpp: In function `int Game_Main(void*)':
    G3D_P1.cpp:184: `KEY_DOWN' undeclared (first use this function)
    G3D_P1.cpp:184: (Each undeclared identifier is reported only once for each 
       function it appears in.)
    G3D_P1.cpp:187: `main_window_handle' undeclared (first use this function)
    Man! This book is really making me mad. I copy the code from this book exacly and the program is all buggy. I"ll attach the .cpp file and you ppl take a look at it.

    Don't werie about there not being comments I used as many as possible so I won't forget things.


    ~Trooper
    Your mom is like a struct, she has no class

    How many C programmers does it take to screw in a light bulb? One to do it, 99 to tell him how to do it faster.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    Looks like you missed an if() statement not long after the comment

    // enter main event loop

    It is probably something like this...

    if (msg.message != WM_QUIT)

    ...but it could be something different.

    Also check that you have the curley braces in the right places around that part of the code.

    The rest of the code looks right.

  3. #3
    using namespace Trooper; St0rmTroop3er's Avatar
    Join Date
    Sep 2003
    Posts
    77
    LOL!!!

    Look atthis error Dev-c++ v4.9.8.0 gives me.

    ...



    ROFL


    ~Trooper
    Last edited by St0rmTroop3er; 10-01-2003 at 11:33 AM.
    Your mom is like a struct, she has no class

    How many C programmers does it take to screw in a light bulb? One to do it, 99 to tell him how to do it faster.

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>what does this error mean?
    >>G3D_P1.cpp:33:19: fcnt1.h: No such file or directory
    Hmm, I'm not sure, but something's telling me the compiler can't find a file
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    This is typical... you will see strange error messages when you have strange errors in your code. Compiler do not cope well with arbitrary input. When you decide to stop complaining about the compiler and get busy fixing your data entry errors you will see that there is nothing wrong with the compiler.

    Your code has atleast two errors... I gave you one of them, now I'll give you another... there is no file named fcnt1.h, but there is a file named fcntl.h (as in "L" not 1)

  6. #6
    using namespace Trooper; St0rmTroop3er's Avatar
    Join Date
    Sep 2003
    Posts
    77
    Code:
    if(KEY_DOWN(VK_ESCAPE))
      {
      // If user presses ESCAPE then exit.
      PostMessage(MAIN_WINDOW_HANDLE, WM_DESTROY,0,0);
      }//end If
    I get an error that says KEY_DOWN undeclared.

    And then is says MAIN_WINDOW_HANDLE undeclared. I wan't it so when the user presses ESCAPE it quits the game.


    This is the last error for this part of my code lol. If I take out the If(KEY_DOWN) it works fine so thats one of my problems.
    ~Trooper
    Last edited by St0rmTroop3er; 10-02-2003 at 03:49 PM.
    Your mom is like a struct, she has no class

    How many C programmers does it take to screw in a light bulb? One to do it, 99 to tell him how to do it faster.

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    Here are some more suggestions...

    Remove all of the include lines except for this one:
    Code:
    #include <windows.h>
    Add this at the top of the file, under the include files section

    Code:
    // Macros //////////////////////////////////////////////////////////////////
    
    #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x08000) ? 1 : 0)
    Add a global variable in the section at the top

    Code:
    HWND main_window_handle;
    Add this after the global variable section

    Code:
    // Function Declarations //////////////////////////////////////////////////////
    
    int Game_Main(void);
    int Game_Shutdown(void);
    int Game_Init(void);
    Add main_window_handle = hwnd; to WinMain after the return(0); that follows CreateWindowEx(). It should look like this:

    Code:
        // create the window
        if (NULL == (hwnd = CreateWindowEx(
            0,                                                   // extended style
            WINDOW_CLASS_NAME,                                   // class
            "Geo 3D Game Engine V1.0 Alpha -- By Ryan Capote ©", // title
            WS_OVERLAPPEDWINDOW|WS_VISIBLE,                      // window style
            0,0,                                                 // initial x,y
            800,600,                                             // initial width, height
            NULL,                                                // handle to parent 
            NULL,                                                // handle to menu
            hInstance,                                           // instance of this application
            NULL)))                                              // extra creation parms
            return 0;
    
        main_window_handle = hwnd;  // <<<===  HERE
    Remove the void *params from these functions

    Code:
    int Game_Main(void *params);
    int Game_Shutdown(void *params);
    int Game_Init(void *params);
    They should all start like this:

    Code:
    int Game_Main()
    int Game_Shutdown()
    int Game_Init()
    I also noticed that Game_Shutdown was mispelled as game_Shutdown in two places.

    Rog

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM