Query regarding syntax used in a header file for socket programming

前端 未结 3 1087
遥遥无期
遥遥无期 2021-01-20 13:32

This is the piece of the code I copied from one of the header file for socket programming.

/* Structure describing an Internet socket address.  */
struct soc         


        
3条回答
  •  忘掉有多难
    2021-01-20 13:44

    It is a macro defined somwhere else. It might be defined as

    #define __SOCKADDR_COMMON(sa_prefix) \
      sa_family_t sa_prefix##family
    

    expanding that, the struct would look like

    struct sockaddr_in
      {
        sa_family_t sin_family;
        in_port_t sin_port;      
     ... 
    

    DO NOT copy this structure into your code. You are supposed to include the header file for your system that declares struct sockaddr_in.

提交回复
热议问题