Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Can You Help Me?

This topic is 6101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In VC I have:
typedef struct 
	BYTE a;
	WORD b;
	WORD c;
	BYTE d[11];
TAL t;
And when I write: sizeof(BYTE) it returns 1 sizoef(WORD) returns 2 So, I think, sizeof(TAL) must be 1 + 2 + 2 + 11 = 16 But, when I write sizeof(TAL) it returns 18! why???

Share this post

Link to post
Share on other sites
struct padding........it is an option you can turn off in msvc.
it is something like an efficiency issue where the compiler will add a few extra bytes so that the cpu likes it more.

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T

Share this post

Link to post
Share on other sites

The first BYTE requires an entire word to store (2 bytes), while the array of 11 bytes also requires an extra byte to keep the structure word-aligned. You can change the alignment, but I wouldn''t recommend that at your current stage.

Don''t worry, it''s normal.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!