don't understand declaration "unsigned int ip_v:4"

Discussion in 'C Programming' started by jian, Oct 24, 2003.

  1. jian

    jian Guest

    Hi,

    I am looking at netinet/ip.h in linux code, and the declaration:
    unsigned int ip_hl:4 make me confused.

    I can understand "unsigned int ip_hl", but, what does ":4" here mean?

    Very grateful to any answer.

    Jian
     
    jian, Oct 24, 2003
    #1
    1. Advertising

  2. In article <>, jian wrote:
    > I am looking at netinet/ip.h in linux code, and the declaration:
    > unsigned int ip_hl:4 make me confused.


    It's probably a bit field in a struct.



    --
    Andreas Kähäri
     
    Andreas Kahari, Oct 24, 2003
    #2
    1. Advertising

  3. jian

    James Hu Guest

    On 2003-10-24, jian <> wrote:
    > I am looking at netinet/ip.h in linux code, and the declaration:
    > unsigned int ip_hl:4 make me confused.
    >
    > I can understand "unsigned int ip_hl", but, what does ":4" here mean?


    This kind of syntax is only allowed for a union or struct field, and
    declares a bit-field. In this case, it is declaring ip_hl to hold
    values that fit in 4 bits.

    -- James
     
    James Hu, Oct 24, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. simon

    Error message I don't understand

    simon, Dec 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    326
    Hatim R
    Dec 5, 2003
  2. m miller

    don't understand error

    m miller, Jan 9, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,760
    smitdso
    Sep 8, 2006
  3. Wayne  Wengert

    Don't Understand

    Wayne Wengert, May 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    382
    Wayne Wengert
    May 1, 2004
  4. Philippe C. Martin
    Replies:
    3
    Views:
    440
    Philippe C. Martin
    May 29, 2005
  5. fl
    Replies:
    5
    Views:
    134
    James Kuyper
    Jan 13, 2014
Loading...

Share This Page