C++ – ‘ULONG_MAX’ was not declared in this scope

c

I am getting this error while compiling a cpp file in GCC 4.8.1 in ubuntu

‘ULONG_MAX’ was not declared in this scope'

the code am trying to compile

header included

#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#include <cstdlib>
#include <cerrno>
#include <cstring>



bool parser<unsigned>::parse(Option &O, const char *ArgName,
                             const std::string &Arg, unsigned &Value) {
  char *End;
  errno = 0; 
  unsigned long V = strtoulul(Arg.c_str(), &End, 0);
  Value = (unsigned)V;
  if (((V == ULONG_MAX) && (errno == ERANGE)) || (*End != 0) || (Value != V))
    return O.error(": '" + Arg + "' value invalid for uint argument!");
  return false;
}

I tried the help from the link
error: 'INT32_MAX' was not declared in this scope
but I couldn't match to my case

Best Answer

ULONG_MAX is defined in the limits.h header file. Putting #include <climits> in with your other includes should fix the issue.

Related Topic