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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:19:01+00:00 2026-06-12T19:19:01+00:00

We need to upgrade our program which use unsigned char as bit mask to

  • 0

We need to upgrade our program which use unsigned char as bit mask to a newer version which use unsigned short as bit mask. I believe there is some difference between them because our program failed using same logic with unsigned char changed to unsigned short. ( That is from the external library we bought. The library upgraded so we need to change the program too ).

Old version:
typedef struct SomeStruct {
    unsigned char   bit_mask;
#       define      SomeStruct_a_present 0x80
#       define      SomeStruct_b_present 0x40
#       define      SomeStruct_c_present 0x20
    X          x;
    Y          y;
    A          a;  /* optional; set in bit_mask
                                * SomeStruct_a_present if
                                * present */

    B          b;  /* optional; set in bit_mask
                                * SomeStruct_b_present if
                                * present */

    C          c;  /* optional; set in bit_mask
                                * SomeStruct_c_present if
                                * present */
} SomeStruct;



New version:
typedef struct SomeStruct {
    unsigned short   bit_mask;
#       define      SomeStruct_x_present 0x8000
#       define      SomeStruct_y_present 0x4000
#       define      SomeStruct_a_present 0x2000
#       define      SomeStruct_b_present 0x1000
#       define      SomeStruct_c_present 0x0800
    X          x;/* optional; set in bit_mask
                                * SomeStruct_x_present if
                                * present */
    Y          y;/* optional; set in bit_mask
                                * SomeStruct_y_present if
                                * present */
    A          a;  /* optional; set in bit_mask
                                * SomeStruct_a_present if
                                * present */

    B          b;  /* optional; set in bit_mask
                                * SomeStruct_b_present if
                                * present */

    C          c;  /* optional; set in bit_mask
                                * SomeStruct_c_present if
                                * present */
} SomeStruct;

I think there are some problem with our current line because the program crash:

Our current method to set the bit_mask:

someStruct.bit_mask = SomeStruct_a_present;
someStruct.bit_mask |= SomeStruct_b_present;
someStruct.bit_mask |= SomeStruct_c_present;
  • 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-06-12T19:19:02+00:00Added an answer on June 12, 2026 at 7:19 pm

    With unsigned short this line

    someStruct.bit_mask = SomeStruct_a_present;
    

    will set value of bitmask to 8192, but with unsigned char the value will be set to 128.

    Reason:

    unsigned short is 2 bytes long and bit mask will be 0010000000000000 (0x2000) however with unsigned char this value will be 10000000 (0x80).

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

Sidebar

Related Questions

I need to upgrade our web services to use WCF instead of ASMX. If
Our project currently uses Crystal Reports for Visual Studio 2008. We need to upgrade
I need to upgrade an RPM installed via YUM, which has an fatal bug
I need to change upgrade the PHP version to at least 5.2.0 for my
Our C++ application hosts Sun's JVM and I need to upgrade it to the
I am trying to work on the upgrade component in our program. This requires
I have to estimate the time we need to upgrade one of our customers
Due to a bug in 10.1 of Adobe reader our users need to upgrade
Our company is preparing for a company-wide upgrade to Windows 7 64-bit. The people
I need to put forward some strong arguments to the management to upgrade our

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.