Hi everyone,
i'm using an class calling SESystem and inside her i declare an variable of BITMAP type. When i try to compile, the compilator show me this errors:
23 D:\Projetos\Cpp\Spectrum Engine\Trunk\SESystem.h expected unqualified-id before numeric constant
D:\Projetos\Cpp\Spectrum Engine\Trunk\SESystem.cpp In member function `void SESystem::SetMouseCursorSprite(char*)':
123 D:\Projetos\Cpp\Spectrum Engine\Trunk\SESystem.cpp 'class SESystem' has no member named 'bmpMouseSpr'
124 D:\Projetos\Cpp\Spectrum Engine\Trunk\SESystem.cpp 'class SESystem' has no member named 'bmpMouseSpr'
Somebody knows what's happening with my code?
Thank's for your answers.
[]'s!
Following the code:
1 | #ifndef _SESYSTEM_H_ |
2 | #define _SESYSTEM_H_ |
3 | |
4 | #include <allegro.h> |
5 | #include "SEScene.h" |
6 | #include "SETime.h" |
7 | #include "SESound.h" |
8 | |
9 | class SESystem |
10 | { |
11 | protected: |
12 | /* |
13 | CONFIGURAÇÃO DA WINDOW |
14 | */ |
15 | int iColorDepth; |
16 | int iWinMode; |
17 | const char *cWinTitle; |
18 | int iHeight; |
19 | int iWidth; |
20 | /* |
21 | CONFIGURAÇÃO DO MOUSE |
22 | */ |
23 | BITMAP *bmpMouseSpr; // <- Error |
24 | float fX; |
25 | float fY; |
26 | /* |
27 | EXTRA |
28 | */ |
29 | int iInputType; |
30 | public: |
31 | SETime Time; |
32 | SESound Sound; |
33 | public: |
34 | SESystem(); |
35 | /* |
36 | SISTEMA |
37 | */ |
38 | void Initialize(); |
39 | void Finish(); |
40 | /* |
41 | CONFIGURAÇÃO DA JANELA |
42 | */ |
43 | void SetWindowSize(int iWinSize); |
44 | void SetWindowColorDepth(int iColorDepth); |
45 | void SetWindowMode(int iWinMode); |
46 | void SetWindowTitle(const char *cWinTitle); |
47 | int GetWindowHeight(); |
48 | int GetWindowWidth(); |
49 | /* |
50 | CONFIGURAÇÃO DO DISPOSITIVO DE ENTRADA |
51 | */ |
52 | void SetInputType(int iInputType); |
53 | /* |
54 | ROTINAS DO TECLADO |
55 | */ |
56 | const char *GetKeyName(); |
57 | /* |
58 | ROTINAS DO MOUSE |
59 | */ |
60 | void SelectMouseCursor(int iCursor); |
61 | void SetMouseCursorSprite(char *cPath); |
62 | void GetMousePosition(); |
63 | float ShowMousePositionX(); |
64 | float ShowMousePositionY(); |
65 | void ShowMouse(); |
66 | void HideMouse(); |
67 | /* |
68 | EXTRA |
69 | */ |
70 | void Message(SEScene &tmpScene, const char *cMsg, int iPosX, int iPosY, int iColor, int iBG); |
71 | void Message(SEScene &tmpScene, const char *cMsg, float *fVar, int iPosX, int iPosY, int iColor, int iBG); |
72 | void Message(SEScene &tmpScene, const char *cMsg, int *iVar, int iPosX, int iPosY, int iColor, int iBG); |
73 | void Message(SEScene &tmpScene, const char *cMsg, unsigned int *uiVar, int iPosX, int iPosY, int iColor, int iBG); |
74 | void Message(SEScene &tmpScene, const char *cMsg, double *dbVar, int iPosX, int iPosY, int iColor, int iBG); |
75 | ~SESystem(); |
76 | }; |
77 | |
78 | #endif |
Looks like you have a #define BITMAP 3 in your code somewhere. It doesn't have to be 3, of course, just any numeric constant.
What CGamesPlay plus:
That's said:
Do not use any name of an allegro function/variables in your code. The library provide you types and functions, no variables you are forced to use ( I know you get it, there are some variables that you are forced to use but they are already created by allegro.h , you commonly just have to use them).
Here we are baby.
Some advises:
1 | /* Follow this advise or do it if you are really knowing what you do */ |
2 | BITMAP *BITMAP; /* forbidden */ |
3 | #define BITMAP something /* forbidden */ |
4 | typedef struct BITMAP /* forbidden */ |
5 | int BITMAP /* forbidden */ |
6 | fload BITMAP /* forbidden */ |
7 | double BITMAP /* forbidden */ |
8 | . |
9 | . |
10 | . |
11 | /* I now that here you get it so I stop sending examples. */ |
12 | |
13 | /* but */ |
14 | |
15 | BITMAP *MyBITMAP /* is valid */ |
16 | int BITMAP_3 /* is valid */ |
17 | double aBITMAP /* is valid */ |
18 | . |
19 | . |
20 | . |
21 | /* I hope you understand now. It think it should be clear for you. */ |
EDIT: BITMAP, SOUND, SCREEN_W, SCREEN_H and some others are Allegro properties. These are accessible only himself or with himself. Be aware that he will try to eat you if you are proud to try it, you are warned. It is a beast men. With some big tooths and all the needed stuff.
I revised my code and didn't find any types like allegro library! I can't understand the "why" of this error, it's totally normal my code and not exist duplicated variables or macros.
):
Thank's for your answers.
#include "SEScene.h" #include "SETime.h" #include "SESound.h"
Please post the contents of these 3 files and any files that they include.
Also: Operating system, compiler version, allegro version.
Ok!
Following the requested codes:
SEScene.h
1 | #ifndef _SESCENE_H_ |
2 | #define _SESCENE_H_ |
3 | |
4 | #include <allegro.h> |
5 | |
6 | class SEScene |
7 | { |
8 | protected: |
9 | BITMAP *bmpBuffer; |
10 | int iHeight; |
11 | int iWidth; |
12 | public: |
13 | SEScene(); |
14 | void CreateScene(int iHeight, int iWidth); |
15 | void RefreshScene(); |
16 | void DrawScene(); |
17 | int ShowSceneHeight(); |
18 | int ShowSceneWidth(); |
19 | BITMAP *GetCurrScene(); |
20 | void DestroyScene(); |
21 | ~SEScene(); |
22 | }; |
23 | |
24 | #endif |
SEScene.cpp
1 | #include "SEScene.h" |
2 | |
3 | SEScene::SEScene() |
4 | { |
5 | } |
6 | |
7 | void SEScene::CreateScene(int iHeight, int iWidth) |
8 | { |
9 | this->iHeight = iHeight; |
10 | this->iWidth = iWidth; |
11 | this->bmpBuffer = create_bitmap(this->iWidth, this->iHeight); |
12 | clear_bitmap(this->bmpBuffer); |
13 | } |
14 | |
15 | void SEScene::RefreshScene() |
16 | { |
17 | clear_bitmap(this->bmpBuffer); |
18 | } |
19 | |
20 | void SEScene::DrawScene() |
21 | { |
22 | blit(this->bmpBuffer, screen, 0, 0, 0, 0, this->iWidth, this->iHeight); |
23 | } |
24 | |
25 | int SEScene::ShowSceneHeight() |
26 | { |
27 | return this->iHeight; |
28 | } |
29 | |
30 | int SEScene::ShowSceneWidth() |
31 | { |
32 | return this->iWidth; |
33 | } |
34 | |
35 | BITMAP *SEScene::GetCurrScene() |
36 | { |
37 | return this->bmpBuffer; |
38 | } |
39 | |
40 | void SEScene::DestroyScene() |
41 | { |
42 | destroy_bitmap(this->bmpBuffer); |
43 | } |
44 | |
45 | SEScene::~SEScene() |
46 | { |
47 | } |
SETime.h
1 | #ifndef _SETIME_H_ |
2 | #define _SETIME_H_ |
3 | |
4 | #include <allegro.h> |
5 | |
6 | class SETime |
7 | { |
8 | protected: |
9 | volatile int iFPS; |
10 | public: |
11 | SETime(); |
12 | void SetFPS(int iFPS); |
13 | void IncFPS(); |
14 | void DecFPS(); |
15 | void GameSpeed(); |
16 | int ShowFPS(); |
17 | ~SETime(); |
18 | }; |
19 | |
20 | #endif |
SETime.cpp
1 | #include "SETime.h" |
2 | |
3 | SETime::SETime() |
4 | { |
5 | } |
6 | |
7 | void SETime::SetFPS(int iFPS) |
8 | { |
9 | this->iFPS = iFPS; |
10 | } |
11 | |
12 | void SETime::IncFPS() |
13 | { |
14 | this->iFPS++; |
15 | } |
16 | |
17 | void SETime::DecFPS() |
18 | { |
19 | this->iFPS--; |
20 | } |
21 | |
22 | void SETime::GameSpeed() |
23 | { |
24 | this->iFPS++; |
25 | } |
26 | |
27 | int SETime::ShowFPS() |
28 | { |
29 | return this->iFPS; |
30 | } |
31 | |
32 | SETime::~SETime() |
33 | { |
34 | } |
SESound.h
1 | #ifndef _SESOUND_H_ |
2 | #define _SESOUND_H_ |
3 | |
4 | #include <allegro.h> |
5 | #include "SEGlobals.h" |
6 | #include "SETypes.h" |
7 | |
8 | class SESound |
9 | { |
10 | protected: |
11 | int iDigiVolume; |
12 | int iMidiVolume; |
13 | MIDI *midiMusic; |
14 | SAMPLE *wavSound; |
15 | int IsLoop; |
16 | public: |
17 | SESound(); |
18 | void SetVolume(int iVolume, int iDevice); |
19 | void LoadSoundFX(SOUNDS *tmpSound); |
20 | void PlaySoundFX(SOUNDS *tmpSound); |
21 | void StopSoundFX(SOUNDS *tmpSound); |
22 | void LoadMusic(SOUNDS *tmpSound); |
23 | void PlayMusic(); |
24 | void StopMusic(); |
25 | void PauseMusic(); |
26 | void ResumeMusic(); |
27 | ~SESound(); |
28 | }; |
29 | |
30 | #endif |
SESound.cpp
1 | #include "SESound.h" |
2 | |
3 | SESound::SESound() |
4 | { |
5 | this->iDigiVolume = 100; |
6 | this->iMidiVolume = 100; |
7 | } |
8 | |
9 | void SESound::SetVolume(int iVolume, int iDevice) |
10 | { |
11 | switch(iDevice) |
12 | { |
13 | case 1: |
14 | this->iDigiVolume = iVolume; |
15 | set_volume(this->iDigiVolume, -1); |
16 | break; |
17 | case 2: |
18 | this->iMidiVolume = iVolume; |
19 | set_volume(-1, this->iMidiVolume); |
20 | break; |
21 | default: |
22 | set_volume(-1, -1); |
23 | break; |
24 | } |
25 | } |
26 | |
27 | void SESound::LoadSoundFX(SOUNDS *tmpSound) |
28 | { |
29 | this->wavSound = load_wav(tmpSound->cPath); |
30 | } |
31 | |
32 | void SESound::PlaySoundFX(SOUNDS *tmpSound) |
33 | { |
34 | play_sample(this->wavSound, this->iDigiVolume, 128, 1000, tmpSound->IsLoop); |
35 | } |
36 | |
37 | void SESound::StopSoundFX() |
38 | { |
39 | stop_sample(this->wavSound); |
40 | } |
41 | |
42 | void SESound::LoadMusic(SOUNDS *tmpSound) |
43 | { |
44 | this->midiMusic = load_midi(tmpSound->cPath); |
45 | this->IsLoop = tmpSound->IsLoop; |
46 | } |
47 | |
48 | void SESound::PlayMusic() |
49 | { |
50 | play_midi(this->midiMusic, this->IsLoop); |
51 | } |
52 | |
53 | void SESound::StopMusic() |
54 | { |
55 | stop_midi(); |
56 | } |
57 | |
58 | void SESound::PauseMusic() |
59 | { |
60 | midi_pause(); |
61 | } |
62 | |
63 | void SESound::ResumeMusic() |
64 | { |
65 | midi_resume(); |
66 | } |
67 | |
68 | SESound::~SESound() |
69 | { |
70 | } |
=)
I didn't ask for any of the cpp files, but I did ask for SEGlobals.h and SETypes.h.
Still haven't seen any problems.
Well, here:
1 | #ifndef _SETYPES_H_ |
2 | #define _SETYPES_H_ |
3 | |
4 | /* |
5 | ESTADO DO JOGO |
6 | */ |
7 | |
8 | typedef enum _GAMESTATE |
9 | { |
10 | PAUSE, |
11 | PLAYING, |
12 | DEMO, |
13 | OPTIONS |
14 | } GAMESTATE; |
15 | |
16 | /* |
17 | INFORMAÇÕES DE ARQUIVOS DE SOM |
18 | */ |
19 | |
20 | typedef struct _SOUNDS |
21 | { |
22 | char *cID; |
23 | char *cPath; |
24 | int IsLoop; |
25 | int iSoundType; |
26 | void *Next; |
27 | void *Prev; |
28 | void *First; |
29 | } SOUNDS; |
30 | |
31 | #endif |
1 | /* |
2 | MACROS: IDENTIFICADORES DE ATRIBUTOS |
3 | |
4 | STR -> FORÇA |
5 | AGI -> AGILIDADE |
6 | DEX -> DESTREZA |
7 | INT -> INTELIGÊNCIA |
8 | WIS -> SABEDORIA |
9 | CAR -> CARISMA |
10 | CON -> CONSTITUIÇÃO |
11 | */ |
12 | |
13 | #define STR 1 |
14 | #define AGI 2 |
15 | #define DEX 3 |
16 | #define INT 4 |
17 | #define WIS 5 |
18 | #define CAR 6 |
19 | #define CON 7 |
20 | |
21 | /* |
22 | MACROS: DEFINIÇÕES DE VÍDEO |
23 | */ |
24 | |
25 | #define WINDOWED GFX_AUTODETECT_WINDOWED |
26 | #define FULLSCREEN GFX_AUTODETECT_FULLSCREEN |
27 | #define WIN_DEFAULT 0 |
28 | #define WIN_320_240 1 |
29 | #define WIN_640_480 2 |
30 | #define WIN_800_600 3 |
31 | #define WIN_1024_768 4 |
32 | #define WIN_1280_1024 5 |
33 | |
34 | /* |
35 | MACROS: TIPOS DE ENTRADA DE DADOS |
36 | */ |
37 | |
38 | #define KEYBOARD 1 |
39 | #define MOUSE 2 |
40 | #define JOYSTICK 3 |
41 | #define KEY_MOUSE 4 |
42 | #define KEY_JOYSTICK 5 |
43 | #define MOUSE_JOY 6 |
44 | |
45 | /* |
46 | MACROS: CORES BÁSICAS |
47 | */ |
48 | |
49 | #define TRANSPARENT -1 |
50 | #define RED makecol(255, 0, 0) |
51 | #define GREEN makecol(0, 255, 0) |
52 | #define BLUE makecol(0, 0, 255) |
53 | #define WHITE makecol(255, 255, 255) |
54 | #define BLACK makecol(0, 0, 0) |
55 | |
56 | /* |
57 | MACROS: TIPOS DE CURSOR DE MOUSE |
58 | */ |
59 | |
60 | #define CURSOR_NONE MOUSE_CURSOR_NONE |
61 | #define CURSOR_ALLEGRO MOUSE_CURSOR_ALLEGRO |
62 | #define CURSOR_ARROW MOUSE_CURSOR_ARROW |
63 | #define CURSOR_BUSY MOUSE_CURSOR_BUSY |
64 | #define CURSOR_QUESTION MOUSE_CURSOR_QUESTION |
65 | #define CURSOR_EDIT MOUSE_CURSOR_EDIT |
66 | |
67 | /* |
68 | MACROS: CONFIGURAÇÕES DE SOM |
69 | */ |
70 | |
71 | #define DIGI_VOLUME 1 |
72 | #define MIDI_VOLUME 2 |
73 | #define MUSIC 1 |
74 | #define SFX 2 |
75 | |
76 | /* |
77 | MACROS: CONFIGURAÇÕES DE DIALOGS |
78 | */ |
79 | |
80 | #define BOX 1 |
81 | #define SHADOW_BOX 2 |
82 | #define BITMAP 3 |
83 | #define TEXT 4 |
84 | #define CENTER_TEXT 5 |
85 | #define RIGHT_TEXT 6 |
86 | #define BUTTON 7 |
87 | #define CHECK_BTN 8 |
88 | #define RADIO_BTN 9 |
89 | #define ICON 10 |
90 | #define KEYBOARD_BTN 11 |
91 | #define EDIT 12 |
92 | #define LISTBOX 13 |
93 | #define TEXTLISTBOX 14 |
94 | #define TEXTBOX 15 |
95 | #define SLIDER 16 |
96 | #define MENU 17 |
97 | |
98 | /* |
99 | MACROS: VERIFICAÇÃO DE DEBUG |
100 | */ |
101 | |
102 | #define DEBUG_TEST (DEBUG == 1) |
103 | |
104 | /* |
105 | MACROS: VERIFICAÇÃO DE COLISÃO DE CENÁRIO |
106 | */ |
107 | |
108 | #define TOP 1 |
109 | #define BOTTON 2 |
110 | #define LEFT 3 |
111 | #define RIGHT 4 |
@GullRaDriel:
WinXP + Mingw 3.3.1 + Allegro 4.2.1
[]'s!
Man am I good. You have it right here:
#define BITMAP 3
That changes the meaning of "BITMAP" everywhere in your code to "3", so your line reads:3 *bmpMouseSpr; // <- ErrorObviously, that's invalid. Solution: change the #define BITMAP.
God... i'm stupid... STUPID!!! -.-""""""""""""""""""
I changed all my code... because THIS... -.-""""""""""""""""""
Ok... this occur... =)))
Thank you so much!
#define BITMAP 3
What did I have said ? hmmm...
EDIT: BITMAP, SOUND, SCREEN_W, SCREEN_H and some others are Allegro properties. These are accessible only himself or with himself. Be aware that he will try to eat you if you are proud to try it, you are warned. It is a beast men. With some big tooths and all the needed stuff.
#define BITMAP something /* forbidden */
You are too good, CGamesPlay. I will had let him searching a little bit more :p
CGamesPlay, where did you get Allegro 5 from? I didn't know it was out yet.
Duh, it's in SVN
Of course, if Kauhiz had it, he'd know you were going to say that.