Skip to content

Compilation error with GCC #33

@mohammad-akhlaghi

Description

@mohammad-akhlaghi

When building flock 0.4.0 with GCC 11.1.0, I get the following compilation error:

src/flock.c: In function ‘main’:
src/flock.c:323:32: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘__suseconds_t’ {aka ‘long int’} [-Werror=format=]
  323 |                 printf("took %1u microseconds\n", (t_l_acq.tv_usec - t_l_req.tv_usec)); // not adding due to time constraints
      |                              ~~^                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                |                                   |
      |                                unsigned int                        __suseconds_t {aka long int}
      |                              %1lu
cc1: all warnings being treated as errors

As the compiler recommends, it can be fixed by simply replacing %1u with %1lu. After making this change Flock was successfully built on my system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions