user136: I have a simple library which uses another library. 
Here is the header:
#ifndef __DERIVEDCLASS_H__
#define __DERIVEDCLASS_H__

#include <HardwareSerial.h>

class DerivedClass
{
private:
    HardwareSerial* serial;

public:
    DerivedClass();
};
#endif

And the CPP:
#include "DerivedClass.h"

DerivedClass::DerivedClass()
{

}

And the sketch:
#include <DerivedClass.h>

void setup()
{
}

void loop()
{
}

This works fine.
However, if I change the library header to this:
#ifndef __DERIVEDCLASS_H__
#define __DERIVEDCLASS_H__

#include <SoftwareSerial.h>

class DerivedClass
{
private:
    SoftwareSerial* serial;

public:
    DerivedClass();
};
#endif

The sketch fails to compile:

/Users/andrew/Documents/Arduino/libraries/DerivedClass/DerivedClass.h:9:
  error: ISO C++ forbids declaration of 'SoftwareSerial' with no type
  /Users/andrew/Documents/Arduino/libraries/DerivedClass/DerivedClass.h:9:
  error: expected ';' before '*' token

If I change the sketch to:
#include <DerivedClass.h>
#include <SoftwareSerial.h>

void setup()
{
}

void loop()
{
}

i.e. including the SoftwareSerial library in the top level sketch, it compiles fine.
If I expand the library out so it actually performs actions, then if it compiles, it works.
Why is this? HardwareSerial is a built-in part of the Arduino, located in hardware/arduino/cores/arduino and SoftwareSerial is in libraries, but why would the build process differentiate between the two.

user84: If I remember correctly this is in fact a limitation of the Arduino IDE.
If you use a better IDE (personally I use Eclipse with the Arduino plugin) it works as it should, i.e. if you include a library A that includes another library B, then in the end you won't get compile-time errors and both B and A will be included in the final binary.

136: <p>I have a simple library which uses another library. </p>

<p>Here is the header:</p>

<pre><code>#ifndef __DERIVEDCLASS_H__
#define __DERIVEDCLASS_H__

#include &lt;HardwareSerial.h&gt;

class DerivedClass
{
private:
    HardwareSerial* serial;

public:
    DerivedClass();
};
#endif
</code></pre>

<p>And the CPP:</p>

<pre><code>#include "DerivedClass.h"

DerivedClass::DerivedClass()
{

}
</code></pre>

<p>And the sketch:</p>

<pre><code>#include &lt;DerivedClass.h&gt;

void setup()
{
}

void loop()
{
}
</code></pre>

<p>This works fine.</p>

<p>However, if I change the library header to this:</p>

<pre><code>#ifndef __DERIVEDCLASS_H__
#define __DERIVEDCLASS_H__

#include &lt;SoftwareSerial.h&gt;

class DerivedClass
{
private:
    SoftwareSerial* serial;

public:
    DerivedClass();
};
#endif
</code></pre>

<p>The sketch fails to compile:</p>

<blockquote>
  <p>/Users/andrew/Documents/Arduino/libraries/DerivedClass/DerivedClass.h:9:
  error: ISO C++ forbids declaration of 'SoftwareSerial' with no type
  /Users/andrew/Documents/Arduino/libraries/DerivedClass/DerivedClass.h:9:
  error: expected ';' before '*' token</p>
</blockquote>

<p>If I change the sketch to:</p>

<pre><code>#include &lt;DerivedClass.h&gt;
#include &lt;SoftwareSerial.h&gt;

void setup()
{
}

void loop()
{
}
</code></pre>

<p>i.e. including the SoftwareSerial library in the top level sketch, it compiles fine.</p>

<p>If I expand the library out so it actually performs actions, then if it compiles, it works.</p>

<p>Why is this? HardwareSerial is a built-in part of the Arduino, located in <em>hardware/arduino/cores/arduino</em> and SoftwareSerial is in <em>libraries</em>, but why would the build process differentiate between the two.</p>
 84: <p>If I remember correctly this is in fact a limitation of the <strong>Arduino IDE</strong>.</p>

<p>If you use a better IDE (personally I use Eclipse with the Arduino plugin) it works as it should, i.e. if you include a library A that includes another library B, then in the end you won't get compile-time errors and both B and A will be included in the final binary.</p>
