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

  • Home
  • SEARCH
  • 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 887067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:10:09+00:00 2026-05-15T13:10:09+00:00

Possible Duplicate: What does this C++ code mean? I’m trying to map a C

  • 0

Possible Duplicate:
What does this C++ code mean?

I’m trying to map a C structure to Java using JNA. I came across something that I’ve never seen.

The struct definition is as follows:

struct op 
{
    unsigned op_type:9;  //---> what does this mean? 
    unsigned op_opt:1; 
    unsigned op_latefree:1; 
    unsigned op_latefreed:1; 
    unsigned op_attached:1; 
    unsigned op_spare:3; 
    U8 op_flags; 
    U8 op_private;
};

You can see some variable being defined like unsigned op_attached:1 and I’m unsure what would that mean. Would that effect the number of bytes to be allocated for this particular variable?

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

    This construct specifies the length in bits for each field.

    The advantage of this is that you can control the sizeof(op), if you’re careful. the size of the structure will be the sum of the sizes of the fields inside.

    In your case, size of op is 32 bits (that is, sizeof(op) is 4).

    The size always gets rounded up to the next multiple of 8 for every group of unsigned xxx:yy; construct.

    That means:

    struct A
    {
        unsigned a: 4;    //  4 bits
        unsigned b: 4;    // +4 bits, same group, (4+4 is rounded to 8 bits)
        unsigned char c;  // +8 bits
    };
    //                    sizeof(A) = 2 (16 bits)
    
    struct B
    {
        unsigned a: 4;    //  4 bits
        unsigned b: 1;    // +1 bit, same group, (4+1 is rounded to 8 bits)
        unsigned char c;  // +8 bits
        unsigned d: 7;    // + 7 bits
    };
    //                    sizeof(B) = 3 (4+1 rounded to 8 + 8 + 7 = 23, rounded to 24)
    

    I’m not sure I remember this correctly, but I think I got it right.

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

Sidebar

Ask A Question

Stats

  • Questions 439k
  • Answers 439k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think this is a bug is the Scala library.… May 15, 2026 at 5:03 pm
  • Editorial Team
    Editorial Team added an answer In the html code you posted, it says <param name="loop"… May 15, 2026 at 5:03 pm
  • Editorial Team
    Editorial Team added an answer This substitution will do it. $ perl -p -e 's/a/++$i/ge'… May 15, 2026 at 5:03 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.