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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:58:13+00:00 2026-05-15T19:58:13+00:00

I have a uint32 variable for some bit field flag state and an enum

  • 0

I have a uint32 variable for some bit field flag state and an enum for these flags. This variable is passed as argument to some functions by value.

I need to add about 20 more flags to it. What are my best options? Extend it to 64 bits or treat it as an array of 2 32bits?

Extending to 64 bits will lead me to use compiler ‘extensions’, as enum is 32bits wide. But using an array seems to lead to more work.

My code compiles on 32 and 64 bit compilers, and runs on windows, linux and mac.

Thanks in advance.

  • 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-15T19:58:13+00:00Added an answer on May 15, 2026 at 7:58 pm

    I would use an STL bitset. Then my enum wouldn’t have to be a power of 2. With normal enumeration, it would just be the index into the bitset. You could also use a vector<bool>.

    The chief benefit would be portability since your flag set would now fit in any platform’s normal enum range.

    example:

    enum errorFlags { parity, framing, overrun, errorFlags_size };
    
    std::bitset<errorFlags_size> flagSet;
    
    . . .
    
    // either of these set framing error condition
    flagSet[framing] = true;
    flagset.set(framing);
    
    // either of these clear the framing error condition
    flagSet[framing] = false;
    flagset.reset(framing);
    
    // this tests for the framing error condition
    if (flagSet[framing])
    {
        // we have a framing error
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 498k
  • 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 String literals are interned, if that's what you're talking about:… May 16, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer How about this: write a class that does one thing… May 16, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer Since you clarified that this regex is to be used… May 16, 2026 at 12:08 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

Related Questions

For example, if I have a 64-bit variable and store two 32-bit items of
I have a class with static method which has a local static variable. I
Basically, I have a matrix class like this (with a lot of operator overloads
I'm currently self-studying C for mastering an university project. In that project we have
I have a hashing method whose operations depend on input to the function. Profiling
I'm porting over some templated code from Windows and I'm hitting some compiler differences
I have: const unsigned int hash_1 = 0xaf019b0c; const unsigned int hash_2 = 0xf864e55c;
I have heard a lot about the importance of programming style. In my opinion,
What chances do I have to instantiate, keep and serialize/deserialize to/from binary data Python
I have the following declaration for DNSServiceRegister: function DNSServiceRegister ( var sdRef: TDNSServiceRef; const

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.