can't include a header file into a cpp file

Hi. I have some problems with include header file in a cpp file. I have a header file in which I define some constants with #define directive. I include this header file into the Morse.cpp file, to use the defined constants. During compilation I get the error message: "BLA is not defined in current context". But I can successfully include the header file in the main pde file. header file: Test.h

#define BLA 5

cpp file: Morse.cpp

#include "WProgram.h"
#include "Test.h"
#include "Morse.h"

Morse::Morse(int pin)
{
  ....
}

void Morse::dot()
{

  Serial.println(BLA);

  ....
}

void Morse::dash()
{
    ....
}

What's the location of the file Test.h? Is it in a folder named Test?

Do you add the statement #include "Test.h" to the main pde? If not, add it.

Unfortunately, snippets won't cut it here. You'll need to post all of your code (warts and all, don't worry about them), and the complete compiler output.

In my example I have extended the Morse Tutorial from Arduino. Morse.h, Morse.cpp and Test.h are in the same folder.
Error Message: error VJS1201: Name “BLA” is not defined in current context.

SOS.pde

#include "Test.h"
#include <Morse.h>


Morse morse(13);

void setup()
{
	Serial.begin(9600);
}

void loop()
{
	Serial.println("loop");
	morse.dot();
//	morse.dot(); morse.dot(); morse.dot();
//	morse.dash(); morse.dash(); morse.dash();
//	morse.dot(); morse.dot(); morse.dot();
	delay(1000);
}

Morse.h

/*
  Morse.h - Library for flashing Morse code.
  Created by David A. Mellis, November 2, 2007.
  Released into the public domain.
*/
#ifndef Morse_h
#define Morse_h

#include "WProgram.h"

class Morse
{
public:
    Morse(int pin);
    void dot();
    void dash();
private:
int _pin;
};

#endif

Morse.cpp

/*
  Morse.cpp - Library for flashing Morse code.
  Created by David A. Mellis, November 2, 2007.
  Released into the public domain.
*/

#include "WProgram.h"
#include "Test.h"
#include "Morse.h"


Morse::Morse(int pin)
{
  pinMode(pin, OUTPUT);
  _pin = pin;
}

void Morse::dot()
{
		Serial.println(BLA);

  digitalWrite(_pin, HIGH);
  delay(250);
  digitalWrite(_pin, LOW);
  delay(250);  
}

void Morse::dash()
{
		Serial.println("dash");
		
  digitalWrite(_pin, HIGH);
  delay(1000);
  digitalWrite(_pin, LOW);
  delay(250);
}

Test.h

#define BLA 5

I got a different message when I compiled your code:

Binary sketch size: 2972 bytes (of a 30720 byte maximum)

Here is a different Morse library. Morse in and out are easy as hell. It’s guaranteed to work :wink: