Skip to content

(Arduino Nano Every) RtcDS3231.h requestFrom() function with ambiguous declaration #196

Description

@Tnthr

Describe the bug
IsDateTimeValid() causes a warning about ambiguous declaration. See below for error output. This can be seen with the DS3231_Simple.ino example script.

In file included from C:\Users\brian\AppData\Local\Temp\.arduinoIDE-unsaved2023730-15568-u5zvlf.mrk2s\DS3231_Simple\DS3231_Simple.ino:18:0:
c:\Users\brian\Source\libraries\Rtc_by_Makuna\src/RtcDS3231.h: In instantiation of 'uint8_t RtcDS3231<T_WIRE_METHOD>::getReg(uint8_t) [with T_WIRE_METHOD = TwoWire; uint8_t = unsigned char]':
c:\Users\brian\Source\libraries\Rtc_by_Makuna\src/RtcDS3231.h:272:32:   required from 'bool RtcDS3231<T_WIRE_METHOD>::IsDateTimeValid() [with T_WIRE_METHOD = TwoWire]'
C:\Users\brian\AppData\Local\Temp\.arduinoIDE-unsaved2023730-15568-u5zvlf.mrk2s\DS3231_Simple\DS3231_Simple.ino:87:30:   required from here
c:\Users\brian\Source\libraries\Rtc_by_Makuna\src/RtcDS3231.h:663:16: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
         size_t bytesRead = _wire.requestFrom(DS3231_ADDRESS, (uint8_t)1);
                ^~~~~~~~~
In file included from C:\Users\brian\AppData\Local\Temp\.arduinoIDE-unsaved2023730-15568-u5zvlf.mrk2s\DS3231_Simple\DS3231_Simple.ino:17:0:
C:\Users\brian\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:63:12: note: candidate 1: size_t TwoWire::requestFrom(int, int)
     size_t requestFrom(int, int);
            ^~~~~~~~~~~
C:\Users\brian\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:61:12: note: candidate 2: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
     size_t requestFrom(uint8_t, size_t);
            ^~~~~~~~~~~

To Reproduce
Steps to reproduce the behavior:

  1. compile DS3231_Simple.ino

Expected behavior
No warnings during compile.

Development environment (please complete the following information):

  • OS: Win10
  • Build Environment: Arduino IDE 2.2.0
  • Board target: Arduino Nano Every
  • Library version: 2.4.2

Minimal Sketch that reproduced the problem:
DS3231_Simple.ino

Additional context
Suggested fix:
Change the type cast to size_t on line 663 of RtcDS3231.h to match the "candidate 2" form of requestFrom().

        // control register
+++     size_t bytesRead = _wire.requestFrom(DS3231_ADDRESS, (size_t)1);
---     size_t bytesRead = _wire.requestFrom(DS3231_ADDRESS, (uint8_t)1);
        if (1 != bytesRead)
        {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalCause is external to this library (does not mean a work around for it isn't a valid solution)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions