EEPROM include will not work inside library ?

I have create a sketch inside the IDE, where I can make simple things with the EEPROM, Then if I am trying to use the EEPROM inside a library class, I get error :

’EEPROM’ was not declared in this scope

In the library ,

#include <stdio.h>
#include <string.h>
#include <Arduino.h>
#include <EEPROM.h>

class EEprom
{
public:
    
    EEprom();
    int save(char *tosave);


private:

 };

In the .cpp file :

#include "EEprom.h"
EEprom::EEprom()
{
    
    EEIndex=0;
    
}

int EEprom::save(char *tosave)
{
    int len=strlen(tosave) ;
    for(int k=0;k<len;k++)
        EEPROM.update(writeIndex+k,tosave[k]);   // erros all over when using EEPROM .
    EEPROM.update(writeIndex+len,'

Whats wrong with EEPROM when its inside a class ? the same works inside a sketch .

I have seen similar behaviour here :
http://forum.arduino.cc/index.php?topic=116028.0);
    writeIndex+=len+1;
   
}


Whats wrong with EEPROM when its inside a class ? the same works inside a sketch .

I have seen similar behaviour here :
http://forum.arduino.cc/index.php?topic=116028.0

**** Very strange solution : you also have to include the EEPROM in your main sketch for this to work ! *****

#include <EEPROM.h>
#include <someLibrary.h>

In this order only (EEPROM first ).

And I thought the include <> is searching inside the default library…

Is there a way to solve that ? this makes the library thing to be less encapsulated .

** Strange thing number 2: if you add the #include <EEPROM.h> to the main sketch, then remove it - it complies! and if you close the IDE and open, you get the error again, till you include it again *****

So you have to add it and remove it, every time you open the IDE .

Has anyone encounter this thing ?

gil22:
** Strange thing number 2: if you add the #include <EEPROM.h> to the main sketch, then remove it - it complies! and if you close the IDE and open, you get the error again, till you include it again *****

So you have to add it and remove it, every time you open the IDE .

Has anyone encounter this thing ?

Or add it and leave it.

You need the libraries to be included into a sketch so the IDE can find the library names and copy it to the build folder.

You have discovered the solution yourself, its not an error, but how the IDE deals with libraries.