#include <iostream> not working in custom library


I am getting a compile error when trying to use a custom libraries within the Arduino 1.0.4 IDE. The libraries compile and run from within Microsoft VS2010.

To test whether they would work in the Arduino IDE, I started by including the lowest level library from the custom libraries in an almost empty sketch and attempted to compile the sketch.

#include <base.h>
BLink BaseLink(2);

void setup() { BaseLink.SetValue(2.5,0); }
void loop() { //nothing here yet }

There were many compile errors. Below are the first two; the rest are either the same error or are consequences of the first errors.

In file included from compile_error.ino:1:
C:\arduino-1.0.4\libraries\network/base.h:40: error: 'ofstream' has not been declared
C:\arduino-1.0.4\libraries\network/base.h:41: error: 'ifstream' has not been declared

Below is the first few lines of the base.h file.


#define NODE_VALUE 0
using namespace std;

class BNode;
class BLink
    static int tid;
    int id;
    double *value;
    BNode *in_node;
    BNode *out_node;
    int value_size;
    BLink( int size=1 );
    ~BLink( void );
    virtual void Save( ofstream &outfile );
    virtual void Load( ifstream &infile );

I chose the base.h file to start because it only had standard libraries included and I thought it would be easy going. The errors start in the base.h file with the first calls to the included iostream file, so that is where I started looking. I thought, maybe, that within the Arduino IDE file structure the header files needed to be somewhere other than the C:\arduino-1.0.4\libraries\ directory, but I could not confirm this by looking online. I can see that the base.h (this is in the librairies directory) IS being seen, but it is the includes within that file that are not being seen during compile time.

I appreciate any direction given toward solving this difficulty.


Where's stdin and stdout on an arduino?

You're going to have to relearn a lot of things about programming when you have four million times less memory. Start by reading some tutorials and looking at the examples