I have been having a problem with my code for quite a while now. It started with trying to reference a const static int of a class in the same class. It caused a strange problem which disallowed any class from reading any of its variables. Even after removing the new code, the problem persisted (and still does). I decided to change from consts to #define-ing all of my constants instead for the time being.
There is quite a bit of code, so if someone feels up to the task then just request the code and I will post it all.
I am desperate and will be incredibly grateful to anyone who even attempts to help or gives my something to try.
You could try a complete project rebuild. In Code::Blocks this is Build->Rebuild. I have found that sometimes only this will clear old dependencies and eliminate ugly, persistent linker errors.
I have also limited it down to being an error with reading the "definitions" header file from another header file.
However, there are other problems with the "Figure.h" to tackle also. Thank you for your patience if you are kind enough to help me still.
NOTE if you feel for some reason the rest of the code is necessary ( it's just more header files that function properly except won't read the definitions either ) just let me know.
In that case the problem is that Definitions.h includes Figure.h. If Definitions.h is included before Figure.h has been included, Figure.h will be included by Definitions.h. Figure.h will try to include Definitions.h but nothing will be included because #pragma once prevents the header from being included more than once so when the Figure class is defined the constants has not yet been defined. The solution is to remove #include "Figure.h" from Definitions.h.
I applied what @Peter87 said to all of my code, and it worked! The only error I have now is when I try to reference my struct outside of Figure.h.
In the header, I have a struct defined as follows:
1 2 3 4 5 6 7
//Figure index
struct FIGURE_TYPE {
//Where to crop the image from
SDL_Rect crop;
int x;
int y;
};
It is a pretty simple concept. It has a rectangle that tells where to crop the image from out of the image file, and an x and y to point out where it will be added to the screen. However, when I try to make an array of these structs a parameter to a function, I get an error.
Error 1 error C2653: 'Figure' : is not a class or namespace name
Error 2 error C2061: syntax error : identifier 'FIGURE_TYPE'
I realize that its just a syntax error on how I reference the struct, but I can't make heads or tails of it. Would you mind explaining it so I can be done with this mess?
Have you defined FIGURE_TYPE inside the Figure class body?
1 2 3 4 5 6 7 8 9 10 11 12
class Figure {
public:
struct FIGURE_TYPE {
//Where to crop the image from
SDL_Rect crop;
int x;
int y;
};
...
};
If you define FIGURE_TYPE outside the class you have to leave out Figure:: in front of FIGURE_TYPE. void set_camera ( SDL_Rect& camera, Figure::FIGURE_TYPE figure_index[FIGURE_COUNT] );
@Peter87 Yes, I did define it inside the Figure class body.
@EssGeEich Although I don't quite understand your fix, I tried it and it didn't work. It says that FIGURE_TYPE is undefined then.