iov[0] = (struct iovec) {
.iov_base = &req,
.iov_len = sizeof(req)
};
I’m trying to convert a bit of code from the ss network utility to c++, and the above and similar keeps giving these errors:
main.cpp|83|error: expected primary- expression before ‘struct’
main.cpp|83|error: expected ‘)’ before ‘struct’
C++ doesn’t support that syntax. Try this:
Or maybe:
What you were trying is a C99 feature called “compound literals”. Also, the
.iov_basething is called a “designated initializer”.