phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression
MIT License
6.92k stars 330 forks source link

gcc argument format warnings observed when building qoibench in a linux environment #155

Closed contriteobserver closed 2 years ago

contriteobserver commented 2 years ago
$ gcc qoibench.c -std=gnu99 -lpng -O3 -o qoibench
qoibench.c: In function ‘png_decode_callback’:
qoibench.c:111:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘png_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  111 | #define ERROR(...) printf("abort at line " TOSTRING(__LINE__) ": " __VA_ARGS__); printf("\n"); exit(1)
      |                           ^~~~~~~~~~~~~~~~
......
  192 |   ERROR("PNG read %d bytes at pos %d (size: %d)", length, read_data->pos, read_data->size);
      |                                                   ~~~~~~
      |                                                   |
      |                                                   png_size_t {aka long unsigned int}
qoibench.c:192:3: note: in expansion of macro ‘ERROR’
  192 |   ERROR("PNG read %d bytes at pos %d (size: %d)", length, read_data->pos, read_data->size);
      |   ^~~~~
qoibench.c: In function ‘benchmark_print_result’:
qoibench.c:361:54: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
  361 |    "libpng:  %8.1f    %8.1f      %8.2f      %8.2f  %8d   %4.1f%%\n",
      |                                                    ~~^
      |                                                      |
      |                                                      int
      |                                                    %8ld
......
  366 |    res.libpng.size/1024,
      |    ~~~~~~~~~~~~~~~~~~~~                               
      |                   |
      |                   uint64_t {aka long unsigned int}
qoibench.c:370:54: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
  370 |    "stbi:    %8.1f    %8.1f      %8.2f      %8.2f  %8d   %4.1f%%\n",
      |                                                    ~~^
      |                                                      |
      |                                                      int
      |                                                    %8ld
......
  375 |    res.stbi.size/1024,
      |    ~~~~~~~~~~~~~~~~~~                                 
      |                 |
      |                 uint64_t {aka long unsigned int}
qoibench.c:380:53: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
  380 |   "qoi:     %8.1f    %8.1f      %8.2f      %8.2f  %8d   %4.1f%%\n",
      |                                                   ~~^
      |                                                     |
      |                                                     int
      |                                                   %8ld
......
  385 |   res.qoi.size/1024,
      |   ~~~~~~~~~~~~~~~~~                                  
      |               |
      |               uint64_t {aka long unsigned int}