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 6947885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:02+00:00 2026-05-27T13:45:02+00:00

struct _USBCHECK_FLAGS { unsigned char DEVICE_DEFAULT_STATE : 1; unsigned char DEVICE_ADDRESS_STATE : 1; unsigned

  • 0
struct _USBCHECK_FLAGS
    {
        unsigned char   DEVICE_DEFAULT_STATE       : 1;
        unsigned char   DEVICE_ADDRESS_STATE       : 1;
        unsigned char   DEVICE_CONFIGURATION_STATE : 1;
        unsigned char   DEVICE_INTERFACE_STATE     : 1;
        unsigned char   FOUR_RESERVED_BITS         : 8;
        unsigned char   RESET_BITS                 : 8;
    } State_bits;

What does :1 and :8 mean?

  • 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-27T13:45:02+00:00Added an answer on May 27, 2026 at 1:45 pm

    Those are bit fields. Basically, the number after the colon describes how many bits that field uses. Here is a quote from MSDN describing bit fields:

    The constant-expression specifies the width of the field in bits. The
    type-specifier for the declarator must be unsigned int, signed int, or
    int, and the constant-expression must be a nonnegative integer value.
    If the value is zero, the declaration has no declarator. Arrays of bit
    fields, pointers to bit fields, and functions returning bit fields are
    not allowed. The optional declarator names the bit field. Bit fields
    can only be declared as part of a structure. The address-of operator
    (&) cannot be applied to bit-field components.

    Unnamed bit fields cannot be referenced, and their contents at run
    time are unpredictable. They can be used as “dummy” fields, for
    alignment purposes. An unnamed bit field whose width is specified as 0
    guarantees that storage for the member following it in the
    struct-declaration-list begins on an int boundary.

    This example defines a two-dimensional array of structures named screen.

    struct 
    {
        unsigned short icon : 8;
        unsigned short color : 4;
        unsigned short underline : 1;
        unsigned short blink : 1;
    } screen[25][80];
    

    Edit: another important bit from the MSDN link:

    Bit fields have the same semantics as the integer type. This means a
    bit field is used in expressions in exactly the same way as a variable
    of the same base type would be used, regardless of how many bits are
    in the bit field.

    A quick sample illustrates this nicely. Interestingly, with mixed types the compiler seems to default to sizeof (int).

      struct
      {
        int a : 4;
        int b : 13;
        int c : 1;
      } test1;
    
      struct
      {
        short a : 4;
        short b : 3;
      } test2;
    
      struct
      {
        char a : 4;
        char b : 3;
      } test3;
    
      struct
      {
        char a : 4;
        short b : 3;
      } test4;
    
      printf("test1: %d\ntest2: %d\ntest3: %d\ntest4: %d\n", sizeof(test1), sizeof(test2), sizeof(test3), sizeof(test4));
    

    test1: 4

    test2: 2

    test3: 1

    test4: 4

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

Sidebar

Related Questions

struct Record { char Surname[20]; char Initial; unsigned short int Gender; //0 = male
struct abcd poly[] = { {Inside,Outside}, {Outside,Inside}, }; What does the above declaration mean?
struct elem { int i; char k; }; elem user; // compile error! struct
struct { char a; int b; } x; Why would one define a struct
typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void
struct myType { vector<char*> ls; }; Here ls is holding pointers to char .
struct person { int age; char name[100]; struct person *next; }; void delfirst(struct person
struct match { char men[64]; char women[64]; char menNum[1000]; char woNum[1000]; }; void printOut();
struct DummyStruct{ unsigned long long std; int type; }; DummyStruct d; d.std = 100;
struct { unsigned resizesCellWidths:1; unsigned numColumns:6; unsigned separatorStyle:3; unsigned allowsSelection:1; unsigned backgroundViewExtendsUp:1; unsigned backgroundViewExtendsDown:1;

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.