Menu

Fixes for compiling with newer compilers e.g. clang-15

Help
Khem Raj
2022-08-15
2023-04-13
  • Khem Raj

    Khem Raj - 2022-08-15

    While using newer llvm/clang we encountered some compiler errors about implicit function declarations and return type.

    setserial.c:639:2: error: call to undeclared function 'close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declarat
    ion]

    close(fd);
    ^
    setserial.c:718:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    main(int argc, char **argv)
    ^
    int
    setserial.c:728:14: error: call to undeclared function 'getopt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declar
    ation]

    while ((c = getopt(argc, argv, "abgGqvVWz")) != EOF) {
    ^

    Attached patch fixes it. Please apply if you find it ok.

     
  • Florian Weimer

    Florian Weimer - 2023-04-13

    Don't you need #include <stdlib.h> as well, for exit?

     

Log in to post a comment.