<div dir="ltr">When compiling this program:<br><br>#include <sys/types.h><br>#include <sys/time.h><br>#include <sys/resource.h><br>#include <sys/wait.h><br><br>void foo(void) {<br> int status;<br> int pid, options;<br>
struct rusage ru;<br> pid = wait3(&status, options, &ru);<br>}<br><br>clang reports:<br>wait3.c:10:15: error: incompatible type passing 'int *', expected '__WAIT_STATUS'<br> pid = wait3(&status, options, &ru);<br>
^~~~~~~<br>1 diagnostic generated.<br><br>But gcc works fine.<br><br>This is the relevant code after preprocessing:<br><br># 1 "/usr/include/bits/waitflags.h" 1 3 4<br># 39 "/usr/include/sys/wait.h" 2 3 4<br>
# 63 "/usr/include/sys/wait.h"<br>typedef union<br> {<br> union wait *__uptr;<br> int *__iptr;<br> } __WAIT_STATUS __attribute__ ((__transparent_union__));<br><br>extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options,<br>
struct rusage * __usage) __attribute__ ((__nothrow__));<br><br>And in the man page for wait3:<br><br>SYNOPSIS<br> #include <sys/types.h><br> #include <sys/time.h><br> #include <sys/resource.h><br>
#include <sys/wait.h><br><br> pid_t wait3(int *status, int options,<br> struct rusage *rusage);<br><br>How should we deal with such case?<br></div>