lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.06k stars 421 forks source link

fix compiler warnings about const-breaking cast #73

Closed Jesin closed 5 years ago

Jesin commented 6 years ago

buffer is already declared as const unsigned char*, which can be transparently accepted by fwrite(). Casting it to char* here just makes compilers complain about "discarding cv-qualifiers", so this commit removes that cast.

lvandeve commented 5 years ago

Hi,

Thank you for the pull request! Before merging I will look if there is a way to fix the issue without casting const away

lvandeve commented 5 years ago

Which compiler gives the warning? Thank you :)

Maybe casting to const void* fixes it?

sezero commented 5 years ago

Which compiler gives the warning?

IIRC, gcc did that for my case.

Maybe casting to const void* fixes it?

Why do you even need the casting? The PR suggests removing the cast, not adding it, and it is correct (I've been using that change for quite some time in my projects.)

lvandeve commented 5 years ago

You are absolutely correct sir :) Somehow I saw the change in the opposite direction!

I will verify why the cast was needed before (may have been a different compiler) and will gladly remove it or change to const void*.

lvandeve commented 5 years ago

Finally got around to check this properly. Looks like the cast was there from the very beginning, so no good reason for it to be there, so can accept the request. Thanks for the fix :)