VScode or PlatformIO doesnt see class declaration

I have the following code. It compiles fine and works in practice but still generates a error in the error list everytime I call my private class functions.

timer.cpp

#include <Arduino.h>
#include <timer.h>

bool MillisTimer::isFinished(int interval, int max_ticks)
{
if (ticks &lt; max_ticks || max_ticks == 0)
{
if ((millis() - previous_ms) &gt; interval)
{
previous_ms = millis();
ticks ++;
interval_trigger = 1;
}
else {interval_trigger = 0;}
}
else {interval_trigger = 0;}
return interval_trigger;
}

void MillisTimer::reset()
{
ticks = 0;
}

unsigned long MillisTimer::returnMillis()
{
return previous_ms;
}

MillisTimer Timer;

timer.h

// timer.h

#ifndef _TIMER_h
#define _TIMER_h

class MillisTimer
{
	public:
		bool isFinished(int interval, int max_ticks);
		void reset();
		unsigned long returnMillis();
	
 	private:
		unsigned long previous_ms;
		int ticks;
		bool interval_trigger;
};

extern MillisTimer Timer;

#endif

Yet when I create an object MillisTimer myTimer(); I recieve an error, that somehow works when compiled. Am I missing some extra declaration outside of my code? I have all the files in src folder which is defined. Ive already tried moving them to lib or include, reinstalling PlatformIO and VScode.

Thanks in advance for any and all help!

What is your platformio.ini?

1 Like

I have just messed around with the go to declaration and found out I might be using a very wrong name for my class, timer.h and timer.cpp seems to already exist in the arduino files.

So I changed the name and got it working with no errors. hopefully this will help people who mess up the same as me.

1 Like

Thanks for the offered help! I was quite sure to have had a error there but it was the wrongfull choice of name.