![]() |
|
Expected Primary-Expression before ',' token |
wolf_wolf17
Member #13,811
December 2011
![]() |
Matthew Leverton
Supreme Loser
January 1999
![]() |
What is this: , j*BlockSize BlockSize,
|
wolf_wolf17
Member #13,811
December 2011
![]() |
Here is the whole part of that code. 1void Map::Draw(BITMAP *Buffer)
2{
3 for (int i = 0; i < mapSizeX; i++)
4 {
5 for (int j = 0; j < mapSizeY; j++)
6 {
7 if (MapFile[i][j] == 1)
8 {
9 rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, makecol(0, 255, 255));
10 }
11 else if (MapFile[i][j] == 2)
12 {
13 rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, makecol(0, 255, 0));
14 }
15 }
16 }
17}
I put the whole thing as an attachment.
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
The code in the first post was missing an addition symbol, and the code in your second post has it. What does it say now? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
wolf_wolf17
Member #13,811
December 2011
![]() |
That line still has plenty of errors, run it for your self and see the vastness it beholds
|
Timorg
Member #2,028
March 2002
|
1#include <allegro.h>
2
3#define mapSizeX 24
4#define mapSizeY 24
5#define BlockSize 30
6
7int MapFile[mapSizeX][mapSizeY];
8
9void Draw(BITMAP *Buffer)
10{
11 for (int i = 0; i < mapSizeX; i++)
12 {
13 for (int j = 0; j < mapSizeY; j++)
14 {
15 if (MapFile[i][j] == 1)
16 {
17 rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, makecol(0, 255, 255));
18 }
19 else if (MapFile[i][j] == 2)
20 {
21 rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, makecol(0, 255, 0));
22 }
23 }
24 }
25}
The above code compiles fine, so it seems you have at least fixed that line. edit: #define ScreenWidth 800 #define ScreenHeight 600 #define BlockSize 40; You probably don't want that ; there, as it means that BlockSize is being globally replaced by 40; Leaving the code looking something like Which probably isn't what you want. Macros are not really much of a necessity for c++ in this context. You could consider using const int for these variables. ____________________________________________________________________________________________ |
wolf_wolf17
Member #13,811
December 2011
![]() |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
There's nothing wrong with that line. The error is somewhere else. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Timorg
Member #2,028
March 2002
|
I edited my post in the time it took people to post. But I found out where the problem was. My previous post attempts to explain it. ____________________________________________________________________________________________ |
wolf_wolf17
Member #13,811
December 2011
![]() |
Can you compile this again and tell me what errors you get?
|
Timorg
Member #2,028
March 2002
|
When the ; is removed, there are no errors. Well I don't link in the allegro library, but the compilation goes fine. Goes off to link with allegro... -------------- Clean: Release in test --------------- Cleaned "test - Release" -------------- Build: Release in test --------------- Compiling: ..\..\..\Downloads\Platform\Platform\Player.cpp Compiling: ..\..\..\Downloads\Platform\Platform\camera.cpp Compiling: ..\..\..\Downloads\Platform\Platform\main.cpp Compiling: ..\..\..\Downloads\Platform\Platform\map.cpp Compiling: ..\..\..\Downloads\Platform\Platform\Platform_private.rc Linking console executable: bin\test.exe Output size is 18.50 KB Process terminated with status 0 (0 minutes, 1 seconds) 0 errors, 0 warnings The 2nd lot of code you posted, that also has a ; issue. 1void Map::Draw(BITMAP *Buffer)
2{
3 for (int i = 0; i < mapSizeX; i++); 4 {
5 for (int j = 0; j < mapSizeY; j++)
6 {
7 if (MapFile[i][j] == 1)
8 {
9 rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, 0, 0 makecol(0, 255, 255)); 10 }
11 else if (MapFile[i][j] == 2);
12 {
13 rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, 0, 0 makecol(0, 255, 0)); 14 }
15 }
16 }
17}
The ; on the 1st marked line is breaking things. The other lines issues relate to a missing comma between 0 and makecol. You might want to look at the function documentation for rectfill and work out what arguments and how many you want to pass to it. ____________________________________________________________________________________________ |
wolf_wolf17
Member #13,811
December 2011
![]() |
Which compiler are you using? if (MapFile[i][j] == 1) //New lookup of 'i' changed for new ISO 'for' scoping for (int i = 0; i < mapSizeX; i++); //Using obsolete binding at 'i' rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, 0, 0 makecol(0, 255, 255)) //Expected Primary-Expression before ',' token x 4,and some other errors similar to that. I get the: Expected Primary-Expression before ',' token, error on line 32 and 36. Edit:
|
Timorg
Member #2,028
March 2002
|
I am using MinGW 4.3.2 as my compiler and using CodeBlocks for my IDE. If you remove the ; from the 1st line I marked, it will mean the scope of i will be what you expect it to be. As for the errors related to the , I guess you still need to fix your "Global.h". ____________________________________________________________________________________________ |
wolf_wolf17
Member #13,811
December 2011
![]() |
How do you mean Fix?
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Quote: 0 makecol(0, 255, 255) You're still missing a comma. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Timorg
Member #2,028
March 2002
|
I posted how to fix that problem and what it was doing to your code. Timorg said: I just had a look at your whole code base, your issue is in "Global.h" #define ScreenWidth 800 #define ScreenHeight 600 #define BlockSize 40; You probably don't want that ; there, as it means that BlockSize is being globally replaced by 40; Leaving the code looking something like
____________________________________________________________________________________________ |
wolf_wolf17
Member #13,811
December 2011
![]() |
When you posted it I didn't read the ; in any of it I just skimmed the post, I feel like a D*ck.
|
Timorg
Member #2,028
March 2002
|
Well don't forget the "D*ck" feeling, it will become your friend. It was with me for the 1st couple of years of programming. Half my posts here are me misunderstanding the question and posting intelligent and long answers that are not even relevant. So I have complete sympathy for you having that feeling. ____________________________________________________________________________________________ |
|