load EEPROMAnything library

I am looking for a way to store variables in the event the Arduino is rebooted. I got the built in EEPROM working but it only stores values from 0-255 and I need to be able to store larger values. I found the EEPROMAnything library here

http://arduino.cc/playground/Code/EEPROMWriteAnything.

However this is my first time trying to load a new library and it is giving me trouble. I followed the instructions and saved this code as EEPROMAnything.h and put it in a new folder I created called EEPROMAnything under the libraries section.

#include <EEPROM.h>
#include <Arduino.h>  // for type definitions

template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
    const byte* p = (const byte*)(const void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          EEPROM.write(ee++, *p++);
    return i;
}

template <class T> int EEPROM_readAnything(int ee, T& value)
{
    byte* p = (byte*)(void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          *p++ = EEPROM.read(ee++);
    return i;
}

After that I reboot the IDE and try to compile the sample code from the playground which does not compile. Here is the sample code I am using.

#include <EEPROM.h>
#include "EEPROMAnything.h"

struct config_t
{
    long alarm;
    int mode;
} configuration;

void setup()
{
    EEPROM_readAnything(0, configuration);
    // ...
}
void loop()
{
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...

    // if they push the "Save" button, save their configuration
    if (digitalRead(13) == HIGH)
        EEPROM_writeAnything(0, configuration);
}

What confuses me is that the libraries I see have a .h and a .c file and this only has a .h file so I think I am missing something. Or maybe I am putting the .h file in the wrong place? If anyone has suggestions on what I am doing wrong I would appreciate it.

I thought it might be helpful f I post the error I am getting as well so here it is.

In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:2:46: error: Arduino.h: No such file or directory
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_writeAnything(int, const T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:6: error: expected initializer before '*' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:9: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'byte' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before ')' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before 'void'

arduino-0023

have you tried upping your arduino code to 1.01 ?

I’m using 1.01 EEPROMAnything works for me

I am using 023 because the breadboard bootloader I am using has trouble with 1.01 for reasons that I can not explain. However, I did consider that I and I tried the IDE 1.01 with the same results.

fbriggs4:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:2:46: error: Arduino.h

Arduino.h doesn't exist in 0023.

The code on the Playground page, Arduino Playground - HomePage, looks like it has been updated to work in 1.01, while the text still refers to library version 0013.

From the release notes for 1.01, http://arduino.cc/en/Main/ReleaseNotes:

The WProgram.h file, which provides declarations for the Arduino API, has been renamed to Arduino.h. To create a library that will work in both Arduino 0022 and Arduino 1.0, you can use an #ifdef that checks for the ARDUINO constant, which was 22 and is now 100. For example:

#if defined(ARDUINO) && ARDUINO >= 100

#include "Arduino.h"
#else
#include "WProgram.h"
#endif

When I did that replacement in 0022, it compiled without complaint. Whether it runs like it should, I can't say.

Thank you for the help, I never would have figured that out! Changing the library so it looks for WProgram.h instead of Arduino.h fixed it and it now compiles in 0023.