This error is inexplicably occurring. Here is the code and output:
timer.cpp:
#include "timer.h"
#include "SDL.h"
#include "SDL_timer.h"
void cTimer::recordCurrentTime()
{
this->previous_t = this->current_t;
this->current_t = SDL_GetTicks();
}
timer.h:
#include "SDL.h"
#include "SDL_timer.h"
class cTimer
{
private:
int previous_t;
int current_t;
float delta_time;
float accumulated_time;
int frame_counter;
public:
void recordCurrentTime();
float getDelta();
void incrementAccumulator();
void decrementAccumulator();
bool isAccumulatorReady();
void incrementFrameCounter();
void resetFrameCounter();
int getFPS();
};
Compiler errors:
make g++ -Wall -I/usr/local/include/SDL -c timer.cpp timer.cpp: In member function ‘void cTimer::recordCurrentTime()’: timer.cpp:6: error: ‘class cTimer’ has no member named ‘previous_t’ timer.cpp:6: error: ‘class cTimer’ has no member named ‘current_t’ timer.cpp:7: error: ‘class cTimer’ has no member named ‘current_t’ make: *** [timer.o] Error 1
Compiler errors after removing the #include “timer.h”
g++ -Wall -I/usr/local/include/SDL -c ctimer.cpp ctimer.cpp:4: error: ‘cTimer’ has not been declared ctimer.cpp: In function ‘void recordCurrentTime()’: ctimer.cpp:5: error: invalid use of ‘this’ in non-member function ctimer.cpp:5: error: invalid use of ‘this’ in non-member function ctimer.cpp:6: error: invalid use of ‘this’ in non-member function make: *** [ctimer.o] Error 1
Works for me. Are you sure you’ve got the right
timer.h? Try this:and verify that it’s what you think it is. If so, try adding
^__^at the beginning of your.hfile and seeing if you get a syntax error. It should look something like this: