Skip to content

Conversation

@martinbudden
Copy link

Fixes float-conversion warning that occurs when compiled with -Wfloat-conversion

@greiman
Copy link
Owner

greiman commented Sep 13, 2025

Thanks for pointing out the warning. Few people use the iostream code that I did many years ago when there were only AVR boards.

I never use pull requests in the release version of SdFat since they often they cause problems with other boards.

I test with a number of boards and static analyzers like Cppcheck and cpplint. These analyzers don't accept C-style castes and I found another warning.

d:\Bill\ArduinoSdFat\libraries\SdFat\src\iostream\ostream.cpp:78:7: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
n = -n;
^
d:\Bill\ArduinoSdFat\libraries\SdFat\src/iostream/istream.h:192:12: note: 'v' was declared here
double v;
^

So please try this mod:

  istream& operator>>(float& arg) {
    double v = 0;
    getDouble(&v);
    arg = static_cast<float>(v);
    return *this;
  }

I will put the mod in SdFat-beta and it will finally be in the release version.

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

Successfully merging this pull request may close these issues.

2 participants