Really strange problem report from the IDE

Hey.
I've written a little class for a 7Segment-Display for myself and want to publish them on github. So I wrote it, wrote a litte(very easy^^) Simulation in Codeblocks and want to test it with the Arduino IDE. I have divide my little Class in 2(.h and .cpp) +1(for all the macros) and put it in a folder, which I include in the IDE. The SourceCode looks so( with the marks, where the other parts are included):

// PART 1: Called Template_7_Segment.cpp
#define GIVEN_OUT {for(int i = 0; i < 7; i++)digitalWrite(vars[i],number_lokal[i]);}

#define NUMBER1_lokal {byte number_lokal[7] = {LOW,HIGH,HIGH,LOW,LOW,LOW,LOW};GIVEN_OUT}
#define NUMBER2_lokal {byte number_lokal[7] = {HIGH,HIGH,LOW,HIGH,HIGH,LOW,HIGH};GIVEN_OUT}
#define NUMBER3_lokal {byte number_lokal[7] = {HIGH,HIGH,HIGH,HIGH,LOW,LOW,HIGH};GIVEN_OUT}
#define NUMBER4_lokal {byte number_lokal[7] = {LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH};GIVEN_OUT}
#define NUMBER5_lokal {byte number_lokal[7] = {LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH};GIVEN_OUT}
#define NUMBER6_lokal {byte number_lokal[7] = {LOW,LOW,HIGH,HIGH,HIGH,HIGH,HIGH};GIVEN_OUT}
#define NUMBER7_lokal {byte number_lokal[7] = {HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW};GIVEN_OUT}
#define NUMBER8_lokal {byte number_lokal[7] = {HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH};GIVEN_OUT}
#define NUMBER9_lokal {byte number_lokal[7] = {HIGH,HIGH,HIGH,HIGH,LOW,HIGH,HIGH};GIVEN_OUT}
#define NUMBER0_lokal {byte number_lokal[7] = {HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW};GIVEN_OUT}

#define FAULT_7_Segment {digitalWrite(varDP,HIGH);}

// Part 2: called SevenSegment.h
class SevenSegment
{
	// here is the include for the Template: #include "Template_7_Segment.cpp"	
	private:
		byte output;	// declaration for the content, which should be given out
		byte vars[7];
		byte varDP;	// only the dotpoint gets an own variable, because I don't know when to use it(helpfully at 4x7Segments or something like that)
		byte GND[2];
		
	public:
		SevenSegment(const byte [],const byte []);	// given the Konstruktor all the cathodes off the 7segment in an array and the common grounds then also in an array
		void writeDec(const byte&);	// writes an Dec on the 7Segment
		SevenSegment operator ++(int dummy);	// overload the increment(postfix) operator for the SevenSegment class
		void counting(const byte&);	// counting from a overgiven number to zero by 1 Second
		void writeChar(const byte&);	// writes an letter or another sign to the 7-Segment(if its implemented in the template-file)

		
	protected:
		SevenSegment(const SevenSegment&);	// having a copy-konstruktor, which only can used in the Class(in the case of development: I need it to overload the increment operator)
};

// Part 3, the implemantation: called SevenSegment.cpp
// #include "sevensegment.h"
SevenSegment::SevenSegment(const byte cathode[], const byte anode[])
{
	for(int i = 0;i < 7;i++)
		vars[i] = cathode[i];
	varDP = cathode[7];
	GND[0] = anode[0];
	GND[1] = anode[1];
}

SevenSegment::SevenSegment(const SevenSegment &copy)
{
	for(int i = 0; i < 7; i++)
		vars[i] = copy.vars[i];
	varDP = copy.varDP;
	GND[0] = copy.GND[0];
	GND[1] = copy.GND[1];
	output = copy.output;
}

void SevenSegment::writeDec(const byte &number)
{
	switch(number)
	{
		case 0: NUMBER0_lokal output = 0; break;
		case 1: NUMBER1_lokal output = 1; break;
		case 2: NUMBER2_lokal output = 2; break;
		case 3: NUMBER3_lokal output = 3; break;
		case 4: NUMBER4_lokal output = 4; break;
		case 5: NUMBER5_lokal output = 5; break;
		case 6: NUMBER6_lokal output = 6; break;
		case 7: NUMBER7_lokal output = 7; break;
		case 8: NUMBER8_lokal output = 8; break;
		case 9: NUMBER9_lokal output = 9; break;
		default: FAULT_7_Segment break;
	}
}

SevenSegment SevenSegment::operator ++(int dummy)
{
	SevenSegment help = *this;
	output++;
	writeDec(output);
	return help;
}

void SevenSegment::counting(const byte &number)
{
	for(int i = number; i >= 0; i--)
	{
		writeDec(i);
		i--;
		delay(1000);
	}
}

The problem is, that if I include this, the Compiler throw the exceptions, that all the types 'byte' in the definition of the Class(Part 2) aren't a type:

sevensegment.h:57: error: 'byte' does not name a type

But if I copy all these things into the Editor and run it then, there aren't mistakes! ( I use the last nightly build version, because I have the Arduino Due). So could anyone think about, why there is this kind of mistake?

P.S. Of course I know, that I could make something like#define byte {unsigned char}, but I want to know, why there is such an stupid (linker) mistake...

Thank you!

It doesn't appear that SevenSegment.cpp includes SevenSegment.h. Nor, does it appear to include Arduino.h.

Why are the macro definitions NOT functions? Why are they in a .cpp file, rather than a .h file?

You are right, it isn't appear, but I have changed it, I've only forgot it to wrote it in the post. So that cannot be the mistake.
What do you meand to include arduino.h? Because I don't understand why I should include this, because I include it into the Arduino IDE...

Why I make macros: In my opinion in this case it is a little bit smarter( I needn't to give the function some data etc and its a little bit easier to do all the macros for all letters etc.).( But I know that isn't very object-oriented;)

Alabamajack:
P.S. Of course I know, that I could make something like#define byte {unsigned char}, but I want to know, why there is such an stupid (linker) mistake...

Hmm, talking of mistakes, take another look at that #define!

Because I don't understand why I should include this, because I include it into the Arduino IDE...

You don't need to understand why to do something in order to know that you DO have to do it. If you are interested in why, there have been plenty of threads that explain how the IDE determines what to compile, and, therefore, what to copy to the build directory.

The library gets compiled as a separate unit from the sketch. It matters not that the sketch knows what a byte is (because Arduino.h defined it) when the library is compiled without including Arduino.h. The compiler is not going to remember that two weeks ago last Tuesday, when compiling some other code, it knew what a byte was.

In my opinion in this case it is a little bit smarter

Well, it isn't. You just tossed the ability of the compiler to detect mistakes out the window. That hardly qualifies as smarter in my book.

If you insist on macros, rather than real functions, you can still define them in a .h file, and include that. #including a cpp file looks like a mistake.

I know that this doesn't work, so I've wrote "something like that"... :slight_smile:
But this doesn't solve my problem, but thanks for your help :slight_smile:

Ok i find you. You're right, i must include the Arduino.h... Oh my god.
But thank you very much