Fix build failure on macOS with Apple Clang 17

While trying to compile the latest master branch on macOS, the build fails with the following log message.

/Users/castor/Projects/gsoc/libssh-mirror/examples/sshd_direct-tcpip.c:348:27: error: use of undeclared identifier 'errno'
348 | strerror(errno));
| ^
/Users/castor/Projects/gsoc/libssh-mirror/examples/sshd_direct-tcpip.c:416:102: error: use of undeclared identifier 'errno'
416 | _ssh_log(SSH_LOG_WARNING, "=== my_fd_data_function", "Reading from tcp socket: %s", strerror(errno));
| ^
/Users/castor/Projects/gsoc/libssh-mirror/examples/sshd_direct-tcpip.c:464:95: error: use of undeclared identifier 'errno'
464 | _ssh_log(SSH_LOG_WARNING, "=== open_tcp_socket", "ERROR opening socket: %s", strerror(errno));
| ^
/Users/castor/Projects/gsoc/libssh-mirror/examples/sshd_direct-tcpip.c:487:91: error: use of undeclared identifier 'errno'
487 | _ssh_log(SSH_LOG_WARNING, "=== open_tcp_socket", "ERROR connecting: %s", strerror(errno));
| ^
4 errors generated.

and

/Users/castor/Projects/gsoc/libssh-mirror/examples/ssh_server.c:583:42: error: use of undeclared identifier 'errno'
583 | authorizedkeys, strerror(errno));
| ^
/Users/castor/Projects/gsoc/libssh-mirror/examples/ssh_server.c:594:18: error: call to undeclared library function 'isspace' with type 'int (int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
594 | if (!isspace((int)p[i])) {
| ^
/Users/castor/Projects/gsoc/libssh-mirror/examples/ssh_server.c:594:18: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
/Users/castor/Projects/gsoc/libssh-mirror/examples/ssh_server.c:658:42: error: use of undeclared identifier 'errno'
658 | authorizedkeys, strerror(errno));

when compiling with Apple clang version 17.0.0 (clang-1700.6.4.2) .

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • Code modified for feature
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated
  • The project pipelines timeout is extended at least to 2 hours.

Reviewer's checklist:

  • Any issues marked for closing are addressed
  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to CONTRIBUTING.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code

Merge request reports

Loading