Include limits.h when using LONG_MAX. Thanks go to Robert Norris <rw_norris@hotmail.com> for reporting this.