Skip to content

Warning of comparison between unsigned and signed variable #48

@George-Doge

Description

@George-Doge

Subject of the issue

After compiling the code, with the libary, I get warning from compiler about comparison between signed and unsigned integer expressions. After examining it I came to conclusion that the variable amtToWrite is the culprit, as it is int.

Your workbench

I am using Arduino Uno board, and coding in PlatformIO. The Library version I am using is 3.2.12.

Steps to reproduce

I downloaded the library and then built the code. I got the warning in the output from file SparkFun_External_EEPROM.

Expected behavior

I assume that amtToWrite could be changed to uint16_t since it is calculated from two uint16_t variables, consequently removing the compiler warning.

Actual behavior

I get this warning output. Beside that I do not know if it breaks something, as the library works for me.

.pio/libdeps/uno/SparkFun External EEPROM Arduino Library/src/SparkFun_External_EEPROM.cpp: In member function 'int ExternalEEPROM::write(uint32_t, const uint8_t*, uint16_t)':
.pio/libdeps/uno/SparkFun External EEPROM Arduino Library/src/SparkFun_External_EEPROM.cpp:888:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (uint16_t x = 0; x < amtToWrite; x++)
                              ~~^~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions