Skip to content

fix compiler warnings about ignored 'const' in EEPROM.h #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bxparks opened this issue Aug 30, 2018 · 1 comment
Closed

fix compiler warnings about ignored 'const' in EEPROM.h #36

bxparks opened this issue Aug 30, 2018 · 1 comment

Comments

@bxparks
Copy link
Contributor

bxparks commented Aug 30, 2018

Two methods in libraries/EEPROM/src/EEPROM.h produce the following compiler warnings:

/home/brian/dev/arduino-1.8.5/portable/packages/arduino/hardware/avr/1.6.21/libraries/EEPROM/src/EEPROM.h:43:30: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
     operator const uint8_t() const       { return **this; }
                              ^
/home/brian/dev/arduino-1.8.5/portable/packages/arduino/hardware/avr/1.6.21/libraries/EEPROM/src/EEPROM.h:92:26: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
     operator const int() const          { return index; }
                          ^

The compiler places the ^ symbol on the second const, right after the (). But the compiler is confused. The problem is actually the first const, which is not needed because these two methods return by value, instead of returning by pointer or reference.

The solution is to simply remove the first const.

It would be nice to get rid of these spurious compiler warnings, because they interfere with debugging when there are other compiler errors or warnings in a program. I always have to remember to skip over these 2 spurious warnings, which can sometimes be visually difficult to do when mixed in with hundreds of other compiler warnings. It's also particularly annoying because these 2 warnings are often the very first warning/error messages, and I'm usually interested in the very first compiler errors, except that these two messages are always right at the top.

I will send a PR shortly after filing this.

@cmaglie
Copy link
Member

cmaglie commented Sep 25, 2018

This should be fixed with #37

@cmaglie cmaglie closed this as completed Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants