Unclear as to what the Error Message means.

I have a INO with the following line...

byte eepromRead = EEPROM.read(0);

The only other line related to EEPROM is

#include <EEPROM.h>

When I compile the program, I am getting the following warning from the compiler. I don't know what it means.

In file included from ....ino:8:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM\src/EEPROM.h:43:30: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]

     operator const uint8_t() const       { return **this; }

                              ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM\src/EEPROM.h:92:26: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]

     operator const int() const          { return index; }

Can anyone tell me what it means and if I should be concerned about it?

it means the way the library was written in a way that's not very useful (the first const is not needed as it's ignored).

it's just a warning and no harm to your code.

The operator, (), is defined to return a const value. The two consts in the declaration are confusing to me, since only pointers need two consts (one to say that the pointer is a const and one to say that the value pointed to is const). Apparently, the compiler agrees with me that one too many const keywords are present, so one is ignored.

Have you looked at the library? Makes reading a datasheet a walk in the park. Just another reason to write your own. The rocket scientists are working at NASA.

EEPROM is just an obfuscating shell on top of avr/eeprom.h. Bypass the "see, I know how to code" facade and deal directly with the gcc library.

author=J-M-L date=1540925522 link=msg=3925936]
~~it's just a warning and no harm to your code. ~~

But, not all warnings are harmless. Some warnings are even more dangerous than errors. Errors could be corrected instantly as these are violating the standard rules. Warnings require sound judgement as to ignore them or look for the clues and correct the codes accordingly.

Edit: Edited in view of Post#6.

@golam - This one is.

That was my point. You are making an abusive generalization of my point.

Please Don’t quote me if you want to make some more general comment.

J-M-L:
This one is.

That was my point. You are making an abusive generalization of my point.

Don’t quote me if you want to make some more general comment please

OK! I stand corrected! I have edited my Post#5.

Thanks

The compiler is pointing to the first character of the second const. How odd. The first is superfluous / generates the warning. (Confirmed with some testing.)

Indeed - the library is saying that the returned element is const (a type qualifier) and functions can only return rvalues whilst type qualifiers apply only to lvalues. So it is ignored

As Paul stated i think it would be fine if the function was to return a pointer (or reference).

DKWatson:
EEPROM is just an obfuscating shell on top of avr/eeprom.h. Bypass the "see, I know how to code" facade and deal directly with the gcc library.

The library source is beyond my level of fluency to try and follow. "**this" is that a pointer to a pointer and where is this declared? I just can't figure all that out... Then, I took your advice and go look at <avr/eeprom.h> and I have

eeprom_write_byte ()

and

eeprom_read_byte ()

as well as word or dword, which is all I really need, ever, I think...
Thank you!

"**this" is that a pointer to a pointer and where is this declared?

What that means is that the this object is a pointer and that it points to something (we'll get to what in a minute) that is also a pointer. If that symbol is an lvalue, it is causing an assignment to the memory location that this points to. If the symbol is an rvalue, it is accessing the memory location that this points to.

lvalue and rvalue can be thought of as being on the left or right of an equal sign. Before anyone jumps on me, yes, I know that that is a gross oversimplification of the terms...

As to where this is declared, it is a hidden member of every class. Each instance of the class has a unique this pointer. Just think of it, in the context of a method, as meaning "Hey, I want to use MY data, not some other instance's data".

In my last program, I only had one byte to read and write from eeprom. It compiled and worked as expected.

byte eepromRead = eeprom_read_byte(0);

In my next project, I have 4 bytes to read and write.

byte lastValueSecondsOnes = eeprom_read_byte(0);
byte lastValueSecondsTens = eeprom_read_byte(1);
byte lastValueMinutesOnes = eeprom_read_byte(2);
byte lastValueMinutesTens = eeprom_read_byte(3);
...
if (lastValueSecondsOnes != eeprom_read_byte(0)) eeprom_write_byte(0, lastValueSecondsOnes);
if (lastValueSecondsTens != eeprom_read_byte(1)) eeprom_write_byte(1, lastValueSecondsTens);
if (lastValueMinutesOnes != eeprom_read_byte(2)) eeprom_write_byte(2, lastValueMinutesOnes);
if (lastValueMinutesTens != eeprom_read_byte(3)) eeprom_write_byte(3, lastValueMinutesTens);

I do not get errors for the lines with address 0, but I get errors for the lines with address 1,2 and 3. The 6 errors all warn of an invalid conversion from 'int' to 'const uint8_t* {aka const unsigned char*}'

C:\....ino:55:47: warning: invalid conversion from 'int' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

 byte lastValueSecondsTens = eeprom_read_byte(1);

                                               ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:25:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,

                 from C:\....ino.cpp:1:

I realize 1 is a integer constant, so I tried typecasting to a byte, then I tried declaring the addresses as constants, but the argument is looking for a pointer. How should I rewrite these lines?

It would be useful to see (at least the signature of) the eeprom_read_byte() function. What type does it expect as the argument? What type does it return?

PaulS:
It would be useful to see (at least the signature of) the eeprom_read_byte() function. What type does it expect as the argument? What type does it return?

I am sorry that I don't know what a signature is in this context, but here is the function from avr/eeprom.h

/** \ingroup avr_eeprom
    Read one byte from EEPROM address \a __p.
 */
uint8_t eeprom_read_byte (const uint8_t *__p) __ATTR_PURE__;

Here is the function for eeprom_write_byte()

/** \ingroup avr_eeprom
    Write a byte \a __value to EEPROM address \a __p.
 */
void eeprom_write_byte (uint8_t *__p, uint8_t __value);

Did you write that function? Why does it take a pointer? A pointer to what?

PaulS:
Did you write that function? Why does it take a pointer? A pointer to what?

No, that is the standard library function.

Perehama:
No, that is the standard library function.

From what library/file?