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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    405
    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,937
    smitdso
    Sep 8, 2006
  3. Wayne  Wengert

    Don't Understand

    Wayne Wengert, May 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    522
    Wayne Wengert
    May 1, 2004
  4. Henri
    Replies:
    0
    Views:
    436
    Henri
    Oct 12, 2004
  5. Matt Berther

    I don't understand inheritance!

    Matt Berther, Dec 3, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    531
    Francois
    Dec 3, 2004
  6. Wayne  Wengert

    Don't Understand This error?

    Wayne Wengert, Mar 3, 2005, in forum: ASP .Net
    Replies:
    10
    Views:
    1,276
    George Christopher
    Jan 4, 2006
  7. Philippe C. Martin
    Replies:
    3
    Views:
    513
    Philippe C. Martin
    May 29, 2005
  8. fl
    Replies:
    5
    Views:
    378
    James Kuyper
    Jan 13, 2014
Loading...