This PR uses the POSIX-standard limits.h header to discover the limits for several variable types in a compliant fashion.
There are several places where gslib needs to discover the maximum value of an unsigned type. Currently, it does so via a narrowing type conversion. For example:
uint limit = -(uint)1
However, these limits are already provided by macros in limits.h. This can avoid possible pitfalls from a narrowing conversion. A more compliant version (implemented in this PR) looks like:
#include <limits.h>
uint limit = UINT_MAX
There was also one place in types.h where LLONG_MIN and LLONG_MAX were set, if long long is requested by the user. Now, these limits are also taken from limits.h
This PR uses the POSIX-standard
limits.h
header to discover the limits for several variable types in a compliant fashion.There are several places where gslib needs to discover the maximum value of an unsigned type. Currently, it does so via a narrowing type conversion. For example:
However, these limits are already provided by macros in
limits.h
. This can avoid possible pitfalls from a narrowing conversion. A more compliant version (implemented in this PR) looks like:There was also one place in
types.h
whereLLONG_MIN
andLLONG_MAX
were set, iflong long
is requested by the user. Now, these limits are also taken fromlimits.h