Linux. SOL_NETLINK not defined

2020-02-14 03:09发布

问题:

I was trying to use SOL_NETLINK in setsockopt in Linux, and got an error saying that SOL_NETLINK is not defined although in included the socket.h file.

Googled for some answers and saw people redefine SOL_NETLINK in their own files due to "Linux header file confusion".

Any explanation for that?

回答1:

I just compile-checked this code on a raspbian PI, and it compiles without any warnings.

#include <sys/socket.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
        printf ("SOL_SOCKET=%d\n", SOL_SOCKET);
        return 0;
}


标签: linux sockets