954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Weird compiler errors

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!

Attachments WeirdErrors.txt (2.21KB)
ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

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

ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

Here are lines 251-278:

else /* catch menu items */
    {         
      switch (nBtnID)
        {
            case ID_EXITGAME : PostQuitMessage(0);
                               break;
            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);
                               break;
            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;
                              ShowPlayerStats(&Player);
                              ShowTheCards();
                              return 0;
                              break;                 
         } /* end switch */
    } /* end else */
    return 0;
} /* end onCommand */

Hope this helps!

ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

I truthfully don't know what the problem is.

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

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 "(" ---Ithink, but I am not sure. GCC shouldn't have these problems...

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

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.....

ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

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...

ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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_GO BITMAP "GOpic.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"

IDI_ULCICON ICON "ULC.ico"

IDD_PLAYERCOUNT DIALOG 0, 0, 145, 60
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    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
}    

IDM_MAINMENU MENU 
{
     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....

ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

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.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

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

ShaneM
Newbie Poster
7 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You