I'm trying to create a Monopoly - style game in C++ using the Dev-C++ IDE, MinGW compiler. I actually wrote this game in BASIC on a TRS-80 back in the early '80s and it worked fine! I've attached a .txt of the code in question with the error codes given. The errors make no sense to me, and I cannot find an error code list with explanations anywhere. Anyone see anything I'm missing? Any help would be appreciated, and if you would like to see the entire project, I will gladly send it to you. Thanks!

Recommended Answers

All 13 Replies

Check line 265, if there is missing semi-colon..

No, I've double and treble checked the syntax... that's why I just don't get it.

Can you post a few lines of code around the error line?

Here are lines 251-278:

else /* catch menu items */
      switch (nBtnID)
            case ID_EXITGAME : PostQuitMessage(0);
            case ID_ABOUTGAME : MessageBox(hwnd,
            TEXT("Written in C++ By Shane Murray\nGraphics by Chad Murray"),
                              TEXT("About Tampopoly v1.0"),MB_OK|MB_APPLMODAL);
            case ID_NEWGAME : LoadCardData();
                              Contestant Player;
                              //NumOfPlayers = GetNumberOfPlayers(nFunsterStil);
                              Player.Name = "Shane";
                              //if (NumOfPlayers > 0) IntoStr(NumOfPlayers,false);
                              NumOfPlayers = DialogBox(g_hInst,
                               MAKEINTRESOURCE(IDD_PLAYERCOUNT), hwnd, DlgProc);
                              Player.Position = 5;
                              return 0;
         } /* end switch */
    } /* end else */
    return 0;
} /* end onCommand */

Hope this helps!

I truthfully don't know what the problem is.

I think that the compiler is complaining that it doesn't know what NumOfPlayers is, or believes it to be something other than a variable. Likewise in your argument list, one of them is not the type of thing it ought to be?

This can occur due to a syntax error (such as forgetting a semi-colon, or mis-matched braces, etc.) in some line above line 265.

It can also occur, amazingly, if you have whitespace other than spaces, tabs, and CR and LF in the lines, and sometimes if you don't put spaces between the "switch" and "(" ---I think, but I am not sure. GCC shouldn't have these problems...

NumOfPlayers is declared as a global int in my header file. I have gone to MSDN to research the DialogBox function, checked and re-checked all my vars, and still can't figure this one out. I had already even deleted all the spaces and CR's in the arguments to DialogBox, and that didn't work either - I've had older compilers for Turbo Pascal and such that complained about spaces - so I understand what you are talking about. This has completely shut down my project, because you can't play if you don't know how many players! I basically need a child window with six buttons on it. I have tried to register a new WINCLASSEX and go that route, but it's not liking that either!! Real hair puller.....

gcc -E file.c > file.i Arrange for the offending file to be compiled like that. What you'll see in the .i file is your source code AFTER the pre-processor has done it's work. For one thing, it will be much longer because all the include files will be expanded. Another is all #defines will have been expanded.

You may find that you have something like 3 = DialogBox(g_hInst,MAKEINTRESOURCE(IDD_PLAYERCOUNT), hwnd, DlgProc); which would indicate that the variable name you're interested in is somehow a macro. It might not help that much, but seeing exactly what the compiler sees is a start. (NumOfPlayers) = DialogBox(g_hInst,MAKEINTRESOURCE(IDD_PLAYERCOUNT), hwnd, DlgProc); Should prevent the macro being expanded, if indeed it is a macro.

Interesting post. After setting the -E parameter on the compiler and reading the ouput, nothing was expanded for the NumOfPlayers variable. You weren't kidding about it being a large file, though. Wow! I also tried putting parenthesis around the NumOfPlayers var, still got the same errors...

Here's another weird one... I tried compiling again, didn't change anything, and those errors are gone. The only error I'm getting now is a syntax error in my resource script file :

#include "Constants.h"

ID_BOARD  BITMAP "BigBoard.bmp"
OBM_ROLL  BITMAP "bnRoll.bmp"
//OBM_Dd2  BITMAP "SkipperRoad.bmp"

OIC_DdPIX0 ICON "PurpleDeed.ico"
OIC_DdPIX1 ICON "LtBlueDeed.ico"
OIC_DdPIX2 ICON "DkPurpleDeed.ico"
OIC_DdPIX3 ICON "OrangeDeed.ico"
OIC_DdPIX4 ICON "RedDeed.ico"
OIC_DdPIX5 ICON "YellowDeed.ico"
OIC_DdPIX6 ICON "GreenDeed.ico"
OIC_DdPIX7 ICON "BlueDeed.ico"
OIC_DdPIX8 ICON "RxRDeed.ico"
OIC_DdPIX9 ICON "UteDeed.ico"


    CAPTION "How many players?"
    DEFPUSHBUTTON "&Cancel", IDCANCEL, 100,35,35,15
    PUSHBUTTON "&6", ID_dSIX, 100,10,35,15
    PUSHBUTTON "&5", ID_dFIV, 55,35,35,15
    PUSHBUTTON "&4", ID_dFOR, 55,10,35,15
    PUSHBUTTON "&3", ID_dTHR, 10,35,35,15
    PUSHBUTTON "&2", ID_dTWO, 10,10,35,15

     POPUP "&Game"
          MENUITEM "&New Game", ID_NEWGAME
          MENUITEM "E&xit", ID_EXITGAME
     POPUP "&About"
          MENUITEM "&Tampopoly", ID_ABOUTGAME

The compiler says syntax error in line 21. I just don't see it....

I'm not that familiar with .rc syntax, but shouldn't there be a comma between DIALOG and the zero (shown in red)?

No, but I think there should be a comma at the end of line 22.

I've never directly made dialogues in an RC file though... If I'm wrong about line 22 I'll have to look it up.

Just to (finally) close the post - Once I #include(d) <Windows.h> in the resource file, it worked fine! Thanks to everybody for taking the time to try to help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.