I've included in my sketch and am trying to run a simple sketch that just does EEPROM.write(0,4); followed by a println of EEPROM.read(0); However, it won't compile. It keeps telling me there is an error, and that I'm making a "request for member 'write' in something that is not a structure or a union". I'm using the Mega ADK. What am I doing wrong? I've also tried to go to sketch->include libraries and include the EEPROM library directly, still no joy. This is Arduino 1.6.13 on Windows 8, if it matters.

  • 3
    You need to list your program ("sketch") for us to help. Guessing, (this is actually C++ so it's going to sound more complex than it really is, but) did you instantiate an instance of the EEPROM class? Did you include the header file for this class in your program?
    – st2000
    Commented Dec 23, 2016 at 15:17
  • 1
    Actually I figured it out. I was using the wrong data types (my sketch wasn't quite what I had shown). I was sending in an unsigned int to the read/write as the address, but it requires an int and the data type is important. Commented Dec 23, 2016 at 15:21
  • 1
    This will sound odd, but in C++ passing the wrong data type is just like calling a totally different method. The up side, you can, for example, write a number of identically named methods that can handle different data types in unique ways. Obviously, the library authors could have done this, but did not. Maybe that is an improvement you can implement.
    – st2000
    Commented Dec 23, 2016 at 15:27
  • I suggest you create an answer to your question. It can then (in a couple of days IIRC) be accepted as the right answer and other people can be helped by it.
    – Majenko
    Commented Dec 23, 2016 at 16:17

1 Answer 1


The problem had to do with data types. I was using an unsigned int as follows:

unsigned int addr = 0;

However, EEPROM.write requires an int, not an unsigned int, and this caused a compiler error.

  • 1
    Also same error if you try to compile eeprom.h (C++) into a C program Commented Oct 22, 2019 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.