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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:55:10+00:00 2026-05-30T07:55:10+00:00

The project that I’ve been working on involves porting some old code. Right now

  • 0

The project that I’ve been working on involves porting some old code. Right now we are using VS2010 but the project is setup to use the VS2008 compiler and tool chain but eventually we will probably move all the way to the VS2010 toolchain. The struct in question looks like this:

struct HuffmanDecodeNode
{
    union
    {
        TCHAR cSymbol;
        struct
        {
            WORD nOneIndex;
            WORD nZeroIndex;
        } cChildren;
    } uNodeData;
    BYTE bLeaf;
}

For reasons that I won’t go into, sizeof(HuffmanDecodeNode) needs to be 8. I’m assuming that on the older compilers this worked out correctly, but now I’m seeing that the size is 6 unless I throw in some padding bytes. #pragma pack(show) confirms that the data should be 4 byte aligned which I assume used to be sufficient, but it appears that the newer compiler only uses this for alignment and doesn’t insert any trailing padding at the end of the struct.

Is there any way that I can control the trailing padding without just adding more struct members?

  • 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-30T07:55:11+00:00Added an answer on May 30, 2026 at 7:55 am

    You can put __declspec( align(8) ) in front of your struct declaration.

    http://msdn.microsoft.com/en-us/library/83ythb65%28v=vs.100%29.aspx

    but…

    WCHAR has size 2 bytes, same for WORD. They both need alignment to 2 bytes only.
    BYTE has size 1 byte and no alignment requirement.

    I don’t think you need the 4 byte alignment in your struct.

    http://msdn.microsoft.com/en-us/library/aa383751%28v=vs.85%29.aspx


    P.S. In GCC you can do the same with __attribute__ ((aligned (8))

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

Sidebar

Related Questions

I have a django project that I have been using for a while, but
I have a project that I'm currently working on but it currently only supports
We have a PHP project that we would like to version control. Right now
The project that I'm currently working on, is large scale. I'm using email activation
I have a project that I have been working on and am closing to
I have a project that isn't using USING anywhere with their ADO.NET code. I
I have a project that I am working on for some simple CSS buttons,
Working on a project that parses a log of events, and then updates a
The project that I am currently working on at the moment uses SVN for
I have a maven project that I run using jetty: $ mvn run:jetty Where

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.