Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 245183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:04:03+00:00 2026-05-11T21:04:03+00:00

I always thought I knew C very well until I saw something like this

  • 0

I always thought I knew C very well until I saw something like this in another post:

struct foo {
    int x:1;
};

I would really like to know the purpose of the :1. Can anybody clue me in? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:04:03+00:00Added an answer on May 11, 2026 at 9:04 pm

    bitfield.
    x is 1 bit long.

    Each field is accessed and manipulated
    as if it were an ordinary member of a
    structure. The keywords signed and
    unsigned mean what you would expect,
    except that it is interesting to note
    that a 1-bit signed field on a two’s
    complement machine can only take the
    values 0 or -1. The declarations are
    permitted to include the const and
    volatile qualifiers.

    The main use of bitfields is either to
    allow tight packing of data or to be
    able to specify the fields within some
    externally produced data files. C
    gives no guarantee of the ordering of
    fields within machine words, so if you
    do use them for the latter reason, you
    program will not only be non-portable,
    it will be compiler-dependent too. The
    Standard says that fields are packed
    into ‘storage units’, which are
    typically machine words. The packing
    order, and whether or not a bitfield
    may cross a storage unit boundary, are
    implementation defined. To force
    alignment to a storage unit boundary,
    a zero width field is used before the
    one that you want to have aligned.

    Be careful using them. It can require
    a surprising amount of run-time code
    to manipulate these things and you can
    end up using more space than they
    save.

    Bit fields do not have addresses—you
    can’t have pointers to them or arrays
    of them.

    http://publications.gbdirect.co.uk/c_book/chapter6/bitfields.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always thought in regex, ^ and # like 'verb' in must follow something,
I always thought that an statement like const int *a means a is an
This may seem like a programming 101 question and I had thought I knew
I always thought base.Something was equivalent to ((Parent)this).Something , but apparently that's not the
I always thought that you could use OR in a LIKE statment to query
I always thought that *&p = p = &*p in C. I tried this
I always thought I understood how this works...but lately I have started really using
I've come across something in C++/CLI that goes against what I thought I knew:
I always thought it's double, until I accidently hit floo+ESC and it told me
Ive always thought this would be cool, and now the OS technology seems it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.