GCC include sequence error

Source: Internet
Author: User

Netlink user layerCodeAs follows:

# Include <Linux/Netlink. h> # include <sys/socket. h> int main () {struct sockaddr_nl src_addr; src_addr.nl_family = af_netlink; src_addr.nl_pid = getpid (); src_addr.nl_groups = 0; return 0 ;}

This is already completeProgramThe following error occurs during GCC Compilation:

# Gcc ccc. cin file encoded ded from CCC. c: 1:/usr/include/Linux/Netlink. h: 35: Error: Expected specifier-qualifier-list before 'sa _ family_t 'CCC. c: In function 'main': CCC. c: 9: Error: 'struct sockaddr_nl 'has no member named' NL _ family 'ccc. c: 10: Error: 'struct sockaddr_nl 'has no member named 'nl _ PID' CCC. c: 11: Error: 'struct sockaddr_nl 'has no member named' NL _ groups'

Why?

Of course, the struct sockaddr_nl does not have the nl_family member as prompted by an error. The problem lies in the include sequence of the header file!

# Include <Linux/Netlink. h> cannot be placed before # include <sys/socket. h>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.