0

Sample code (t4.c):

#include <limits.h>
#include <stdio.h>

int main(void)
{
        printf("%lld\n", LLONG_MIN);
        return 0;
}

Invocation:

$ gcc t4.c && OUT=$(./a.exe) && echo "long long ll = $OUT""ll;" | gcc -xc - -c
<stdin>:1:17: warning: integer constant is so large that it is unsigned

# extra
$ gcc t4.c && OUT=$(./a.exe) && echo "long long ll = $OUT""ll;"
long long ll = -9223372036854775808ll;

Question: why one cannot initialize long long with printed LLONG_MIN? How to fix?

pmor
  • 4,392
  • 3
  • 15
  • 27
  • 1
    Where are you running into that problem? That is a badly formed definition of `LLONG_MIN`. On a 2’s-complement.machine (almost any machine you'relikely to run across), the constant should be formed as `(-LLONG_MAX-1)` or equivalent to avoid the issue. – Jonathan Leffler Aug 21 '21 at 15:28

0 Answers0