Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

extEEPROM::read() fix error and make it debuggable#9

Open
dwrobel wants to merge 1 commit intoPaoloP74:masterfrom
dwrobel:dw-fix-read-for-stm32
Open

extEEPROM::read() fix error and make it debuggable#9
dwrobel wants to merge 1 commit intoPaoloP74:masterfrom
dwrobel:dw-fix-read-for-stm32

Conversation

@dwrobel
Copy link

@dwrobel dwrobel commented Apr 29, 2019

Fixes the follwing compilation errors on the STM32 platform:

extEEPROM/extEEPROM.cpp: In member function 'byte extEEPROM::read(long unsigned int, byte*, unsigned int)':
extEEPROM/extEEPROM.cpp:185:51: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [-Werror]
communication->requestFrom(ctrlByte, nRead);
^
In file included from extEEPROM/extEEPROM.h:62,
from extEEPROM/extEEPROM.cpp:58:
STM32/hardware/stm32/1.6.0-dev/libraries/Wire/src/Wire.h:98:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
uint8_t requestFrom(int, int);
^~~~~~~~~~~
STM32/hardware/stm32/1.6.0-dev/libraries/Wire/src/Wire.h:95:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
uint8_t requestFrom(uint8_t, uint8_t);
^~~~~~~~~~~
cc1plus: all warnings being treated as errors
Using library extEEPROM at version 3.4.1 in folder: extEEPROM
Using library Wire at version 1.0 in folder: .arduino15/packages/STM32/hardware/stm32/1.6.0-dev/libraries/Wire
exit status 1
make: *** [makefile.stm32:67: build] Error 1

Tested using: https://github.com/stm32duino/Arduino_Core_STM32

Also:

  • Modernize the read() method to use 'const' where the variable
    is not modified after assignment.
  • Remove C-like casts and use C++ static_cast<>.
  • Make the code debuggable, by moving 'return' statements to a
    separate line, as on STM32 platform debugger is widely available.

Fixes the follwing compilation errors on the STM32 platform:

extEEPROM/extEEPROM.cpp: In member function 'byte extEEPROM::read(long unsigned int, byte*, unsigned int)':
extEEPROM/extEEPROM.cpp:185:51: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [-Werror]
         communication->requestFrom(ctrlByte, nRead);
                                                   ^
In file included from extEEPROM/extEEPROM.h:62,
                 from extEEPROM/extEEPROM.cpp:58:
STM32/hardware/stm32/1.6.0-dev/libraries/Wire/src/Wire.h:98:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
     uint8_t requestFrom(int, int);
             ^~~~~~~~~~~
STM32/hardware/stm32/1.6.0-dev/libraries/Wire/src/Wire.h:95:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
     uint8_t requestFrom(uint8_t, uint8_t);
             ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
Using library extEEPROM at version 3.4.1 in folder: extEEPROM
Using library Wire at version 1.0 in folder: .arduino15/packages/STM32/hardware/stm32/1.6.0-dev/libraries/Wire
exit status 1
make: *** [makefile.stm32:67: build] Error 1

Tested using: https://github.com/stm32duino/Arduino_Core_STM32

Also:
 - Modernize the read() method to use 'const' where the variable
   is not modified after assignment.
 - Remove C-like casts and use C++ static_cast<>.
 - Make the code debuggable, by moving 'return' statements to a
   separate line, as on STM32 platform debugger is widely available.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant