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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:18:08+00:00 2026-05-27T14:18:08+00:00

I was recently integrating two applications running on different hardware architectures – among the

  • 0

I was recently integrating two applications running on different hardware architectures – among the problems that came up were network-byte-ordering issues and structure padding issues.

Both were easy enough to fix – for the padding specifically, I just had to add pragmas around my networking structs as so:

#pragma pack(1)
struct {};
#pragma pack(0)

I saw a couple of questions relating to bitfields yesterday though which I have never used. I was wondering… would it have been more right to try and stop the padding by defining the structs using bitfields? Would that have helped at all in this scenario?

Also, I haven’t run into bitfields much in C++ code – are they more of a C thing that isn’t used as much or have I just happened to work on code that doesn’t use them?

  • 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-27T14:18:09+00:00Added an answer on May 27, 2026 at 2:18 pm

    No, bitfields are a horrible choice for external representations, such as network packet definitions. It’s completely up to the compiler to select the layout in memory of the bitfield (in which way bits are ordered, how many bytes are reserved for a given field, and so on), so you absolutely kill interoperability.

    That said, I’m opposed using “naked” structures for this as well, for the reasons you’ve run into.

    In my view, the proper way is to serialize/de-serialize the fields one by one, manually.

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

Sidebar

Related Questions

Recently I came across a problem that asks to find out the non-unique characters
We have been thinking recently about integrating our J2EE system with other applications written
Recently, I started changing some of our applications to support MS SQL Server as
I'm fairly new to coding and just recently started working on integrating functions into
Recently I've seen some C# projects that use a double-checked-lock pattern on a Dictionary
Recently I was searching for icons(graphics), but I see a link that was very
There seem to be two rival Eclipse plugins for integrating with Maven: m2Eclipse and
Microsoft recently announced that the Javascript/HTML DOM library jQuery will be integrated into the
I have a system that we have recently developed - a web application over
I've recently taken an existing ASP.NET 3.5 web forms application that was upgraded to

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.