EEPROM Write/Read Issue ( 'EEPROM' does not name a type )

Hi all,

i got a problem writing on the EEPROM.

EEPROM.write(0, 0);
EEPROM.write(1, 0);
EEPROM.write(2, 0);

Gives me this Error

finalcode.cpp: At global scope:
finalcode.cpp:9:1: error: ‘EEPROM’ does not name a type
void analogRead();
finalcode.cpp:10:1: error: ‘EEPROM’ does not name a type
void ANALOGREAD();
finalcode.cpp:11:1: error: ‘EEPROM’ does not name a type
bool httpPost();
make: *** [finalcode.o] Error 1

And also this, but i do not think this has sth. to do with this.

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:29,
from finalcode.cpp:8:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
#warning "Defaulting to Release Build"
In file included from …/inc/spark_wiring.h:37:0,
from …/inc/application.h:29,
from finalcode.cpp:8:
…/inc/spark_wiring_ipaddress.h: In member function ‘IPAddress::operator uint32_t()’:
…/inc/spark_wiring_ipaddress.h:53:52: warning: dereferencing
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
operator uint32_t() { return ((uint32_t)_address); };
…/inc/spark_wiring_ipaddress.h: In member function ‘bool IPAddress::operator==(const IPAddress&)’:
…/inc/spark_wiring_ipaddress.h:54:72: warning: dereferencing
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
bool operator==(const IPAddress& addr) { return (((uint32_t)_address)) == (((uint32_t)addr._address)); };
…/inc/spark_wiring_ipaddress.h:54:105: warning: dereferencing
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
bool operator==(const IPAddress& addr) { return (((uint32_t)_address)) == (((uint32_t)addr._address)); };

What do i wrong ?
Thx

Hi @dongamelo,

Make sure you included the library you’re trying to use. :slight_smile:

Thanks!
David

1 Like

@Dave, @dongamelo is trying to use the built-in EEPROM emulation added a while back. I would need to see finalcode.cpp to see the relevant area but my first guess is that #include “application.h” my be missing.

2 Likes

Thx @Dave,@peekay123,

peekay was right, i wanted to use the built-in EEPROM. Now i know the Problem

EEPROM.write(0, 0); // Gives
EEPROM.write(1, 0); // us
EEPROM.write(2, 0); // Error

void setup() 
{
    EEPROM.write(0, 0); //Works
    EEPROM.write(1, 0);
    EEPROM.write(2, 0);
}

void loop() {}

Didn´t know that this makes a Difference :smiley:

Thx

1 Like

@dongamelo, you were calling EEPROM outside of a function (in this case, setup()) which is not allowed. As soon as you moved the code inside the function, all worked as expected :wink:

2 Likes