argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
377 stars 65 forks source link

Explicit downcast from long int, allows clean build under clang. #17

Closed RobertoMachorro closed 5 years ago

RobertoMachorro commented 6 years ago

ival is a *int type, val is long int, the downcast is happening regardless, this just makes it explicit for LLVM (inc MacOS).

tomghuang commented 5 years ago

@RobertoMachorro Thank you for this pull request. This pull request will cause conflict with the latest code, so I will manually add it. The downcast should be safe, because we have the following check above this downcast:

if ( val > INT_MAX || val < INT_MIN )
            errorcode = ARG_ERR_OVERFLOW;

By the way, I build the code on Ubuntu with Clang-7, but I don't see any Clang warning for this statement. I will check it again on the Mac platform.