fjrg76
February 17, 2022, 9:04pm
1
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?
I want to know.
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!
DaveX
February 17, 2022, 9:25pm
5
1 Like
gfvalvo
February 17, 2022, 9:44pm
6
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
fjrg76
February 18, 2022, 1:31am
8
Thank you! I overlooked that.
fjrg76
February 18, 2022, 1:39am
9
Thank you!
But I was looking for the Arduino's implementation
I was pointed out that such implementation is templetized into the header file EEPROM.h
fjrg76
February 18, 2022, 1:57am
11
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!
system
Closed
August 17, 2022, 1:57am
12
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.