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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:03:40+00:00 2026-06-16T11:03:40+00:00

Possible Duplicate: Why does ‘sizeof’ give wrong measurement? I have a structure called CBUFFER_PEROBJECT:

  • 0

Possible Duplicate:
Why does ‘sizeof’ give wrong measurement?

I have a structure called CBUFFER_PEROBJECT:

struct CBUFFER_PEROBJECT
{
    D3DXMATRIX Final;
    D3DXMATRIX Rotation;
};

And in another class I do this:

...
bd.ByteWidth = sizeof(CBUFFER_PEROBJECT); 
...

I found out that the size of D3DXMATRIX is 64, so 64+64 = 128 (right?). But my compiler is playing tricks with me (Visual C++), because as I was debugging the program, the bd.ByteWidth became 132, so I went to the Immediate Window (Visual Studio), and typed:

sizeof(D3DXMATRIX) + sizeof(D3DXMATRIX)

And the result was:

128

But the bd.ByteWidth became 132, and when I type the following into the “Immediate Window”:

sizeof(CBUFFER_PEROBJECT)

It gives me:

128
  • 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-16T11:03:42+00:00Added an answer on June 16, 2026 at 11:03 am

    Sometimes when compilers are evaluating structure declarations, they will add bytes of padding between fields. This is because some types perform better when aligned to memory addresses that are multiples of their length.

    I’d go so far as to say it’s very likely that you would not see this effect in the immediate window.

    Given these grounds, this is a duplicate question. You can get a more in-depth answer here: Why isn't sizeof for a struct equal to the sum of sizeof of each member?

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

Sidebar

Related Questions

Possible Duplicate: Why does the background of TextView change it's size? I have a
Possible Duplicate: Does an abstact classes have a VTABLE? Does a vtable gets created
Possible Duplicate: Does SQL Server 2005 have an equivalent to MySql’s ENUM data type?
Possible Duplicate: Why does javascript replace only first instance when using replace? I have
Possible Duplicate: Does Dispose method still get called when Exception is thrown inside of
Possible Duplicate: Does std::list::remove method call destructor of each removed element? I have a
Possible Duplicate: Does an open-ended interval implementation exist for Java? i have an int
Possible Duplicate: Does $_REQUEST have security problem? Does anyone have verifiable citations on this?
Possible Duplicate: Does anyone have a good Proper Case algorithm I am currently in
Possible Duplicate: Does every Core Data Relationship have to have an Inverse? I am

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.