Skip to content

Compiler issue from siginfo_t, waitid, ... #7512

@MichaelChirico

Description

@MichaelChirico

#7428 introduced some higher compiler requirements than 1.17.0:

data.table/src/utils.c

Lines 688 to 695 in e455714

int *ppids = INTEGER(pids);
R_xlen_t len = xlength(pids);
SEXP ret = allocVector(LGLSXP, len);
int *pret = LOGICAL(ret);
siginfo_t info;
for (R_xlen_t i = 0; i < len; ++i)
pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
return ret;

I get these compiler errors:

src/utils.c:692:3: error: use of undeclared identifier 'siginfo_t'
  692 |   siginfo_t info;
      |   ^~~~~~~~~
src/utils.c:694:15: error: call to undeclared function 'waitid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |               ^
src/utils.c:694:15: note: did you mean 'waitpid'?
.../sys/wait.h:111:16: note: 'waitpid' declared here
  111 | extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
      |                ^
src/utils.c:694:22: error: use of undeclared identifier 'P_PID'
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |                      ^~~~~
src/utils.c:694:40: error: use of undeclared identifier 'info'
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |                                        ^~~~
src/utils.c:694:46: error: use of undeclared identifier 'WCONTINUED'
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |                                              ^~~~~~~~~~
src/utils.c:694:59: error: use of undeclared identifier 'WEXITED'
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |                                                           ^~~~~~~
src/utils.c:694:79: error: use of undeclared identifier 'WNOWAIT'
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |                                                                               ^~~~~~~
src/utils.c:694:89: error: use of undeclared identifier 'WSTOPPED'
  694 |     pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
      |                                                                                         ^~~~~~~~
8 errors generated.

I fixed it by changing -std=c11 to -std=gnu99, but this is a (mildly) breaking change. Can it be avoided? Or can we add more header guards to work around this / improve the mode of failure?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions