The macro SUN_LEN
expects the passed structure to be a pointer, so you should use SUN_LEN(&name)
.
Compiler error when calling connect(2) with sockaddr_un
-
21-04-2022 - |
Domanda
I am making a simple call to connect(2), in a C++ program. The code is:
connect(socket_fd, (struct sockaddr *)&name, SUN_LEN(name));
(here, name
is a struct sockaddr_un
).
When I try to compile this, I get the following error from g++:
error: base operand of '->' has non-pointer type 'sockaddr_un'
I am totally baffled by this, because I'm not using the -> operator anywhere in the program! Is there something wrong with the way I'm taking the address of name
, or the way I am casting it?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow