We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have a look at the union here: http://man7.org/linux/man-pages/man3/cmsg.3.html
struct msghdr msg = {0}; struct cmsghdr *cmsg; int myfds[NUM_FD]; /* Contains the file descriptors to pass. */ union { /* ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_SPACE(sizeof myfds)]; struct cmsghdr align; } u; int *fdptr; msg.msg_control = u.buf; msg.msg_controllen = sizeof u.buf; cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(int) * NUM_FD); /* Initialize the payload: */ fdptr = (int *) CMSG_DATA(cmsg); memcpy(fdptr, myfds, NUM_FD * sizeof(int));
On clang, the current code fails with an alignment warning for me.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Have a look at the union here: http://man7.org/linux/man-pages/man3/cmsg.3.html
On clang, the current code fails with an alignment warning for me.
The text was updated successfully, but these errors were encountered: