Where is the EEPROM implementation file?

Hi,

I need to see how the bundled EEPROM library has been implemented for the Arduino UNO boards, but I can't locate the EEPROM.cpp file implementation.

Following the compilation output path:

Using the EEPROM library (more info) .../hardware/arduino/avr/libraries/EEPROM

I only found the EEPROM.h interface file and the examples.

Is that possible that you lead me to such file?

Why am I doing this?

  1. I want to know.
  2. I don't like to pass a complete complex object to a function (Programming 101). From the eeprom_get example:
struct MyObject {
  float field1;
  byte field2;
  char name[10];
};

void secondTest() {
  int eeAddress = sizeof(float);

  MyObject customVar; 
  EEPROM.get(eeAddress, customVar); // HERE IT'S SENDING A COMPLETE OBJECT!

  Serial.println("Read custom object from EEPROM: ");
  Serial.println(customVar.field1);
  Serial.println(customVar.field2);
  Serial.println(customVar.name);
}

Thank you in advanced!

Why not?

Why don't you tell us?

A search for "arduino github eeprom" pointed me here: ArduinoCore-avr/libraries/EEPROM/src at master · arduino/ArduinoCore-avr · GitHub

Then "github avr/eeprom.h" has avr/eeprom.h at 460e75ddf58442efc44618eaed87790c7deed7d3 · Synapseware/avr · GitHub

1 Like

I believe (for Uno anyway), there is no EEPROM.cpp. As the library only consists of struct definitions and template functions, the entire implementation is in EEPROM.h. At the end of that file you'll notice:

static EEPROMClass EEPROM;

Because it's static, each Translation Unit that #includes EEPROM.h will have its own (hidden from others) copy of the EEPROM object.

1 Like

Thank you! I overlooked that.

Thank you!

But I was looking for the Arduino's implementation :+1:t2:

I was pointed out that such implementation is templetized into the header file EEPROM.h

Hi,

After looking into the .get() method (thank you to @gfvalvo):

template< typename T > T &get( int idx, T &t ){...}

is clear that one isn't passing the whole object, but a reference. That's what I wanted to see!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.