1

I'm trying to compile this simple code in Windows using MinGW-W64

    #include <stdio.h>
    #include <stdlib.h>

    int main () {
      printf("%llu\n", sizeof(unsigned int)*8);
    }

but when i compile the output of gcc is this:

llu.c: In function 'main':
llu.c:5:15: warning: unknown conversion type character 'l' in format [-Wformat=]
 printf("%llu\n", sizeof(unsigned int)*8);
           ^
llu.c:5:12: warning: too many arguments for format [-Wformat-extra-args]
 printf("%llu\n", sizeof(unsigned int)*8);
        ^~~~~~~~
llu.c:5:15: warning: unknown conversion type character 'l' in format [-Wformat=]
 printf("%llu\n", sizeof(unsigned int)*8);
           ^
llu.c:5:12: warning: too many arguments for format [-Wformat-extra-args]
 printf("%llu\n", sizeof(unsigned int)*8);

It seems as if %llu isn't a valid type but it should be. If i replace %llu with %lu it says sizeof(unsigned int)*8 requires long long int

Can somebody help me fix this please?

  • Which gcc version are you using? Do you have any unprintable characters in the file? – KamilCuk Dec 10 '20 at 10:22
  • 1
    The file is just those few lines i've posted. My gcc version is 8.1.0 – Alessandro Costantini Dec 10 '20 at 10:27
  • Aside: please use `%zu` to match `sizeof`. – Weather Vane Dec 10 '20 at 10:36
  • On my machine your code is compiling and working ( Target: x86_64-suse-linux, Thread model: posix, gcc version 7.5.0 (SUSE Linux) ) – ralf htp Dec 10 '20 at 11:10
  • I could reproduce with Mingw gcc 8.1.0 and `gcc -Wall -pedantic`. It looks like a bug in the library. FYI, I could not reproduce with gcc 9.3.0 on FreeBSD 12. After some more research, the answer is in that other [SO post](https://stackoverflow.com/a/13590809/3545273). – Serge Ballesta Dec 10 '20 at 11:11

0 Answers0