Add #include <limits.h>. Thanks to John McCabe-Dansted