LLONG_MAX is missing for g ++ 4.9.4?

I tried to debug big this simple code:

#include "limits.h"

int main()
{
  long long a = LLONG_MAX;

  return 0;
}

If I run it just like

g++ test.cpp

I get

test.cpp: In function โ€˜mainโ€™:
test.cpp:5:17: error: โ€˜LLONG_MAXโ€™ undeclared (first use in this function)
long long a = LLONG_MAX;

I checked the link for this constant, which says:

LLONG_MIN, LLONG_MAXand are ULLONG_MAXdefined for libraries in accordance with the C standard of 1999 or later (which includes only the C ++ standard since 2011: C ++ 11).

so I tried to install -std=c++11but didn't help. Any suggestions?

PS the same code compiles on other machines with g ++ 5.4.0

Updates: LONG_MAX is displayed (but LLONG_MAX is not), debian4 machine

+4
source share
2 answers

Debian 4 glibc, C99. GCC, glibc. , Debian 4.

glibc - C Debian Linux.

C, Debian.

- GNU , , glibc, , C99 GNU:

g++ -std=gnu++11 test.cpp

LLONG_MAX :

grep -r LLONG_MAX /usr/include

, . - , , LLONG_MAX, ( -D).

++, tpr / . std::numeric_limits , .

, . glibc Debian.

+4

++ std:: numeric_limits

#include <limits>
...
std::numeric_limits<long long>().max();

, c , #include <climits>

+1

Source: https://habr.com/ru/post/1688695/


All Articles