Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

sizeof()

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 SoGreen   Members   

122
Like
Likes
Like

Posted 09 August 2001 - 09:56 AM

I ran into a little problem today using sizeof() and was hoping someone could clear it up for me. Im writing a basic 3ds loader and have a struct declared like so: struct _3DSCHUNKHEADER { WORD ChunkID; DWORD ChunkLength; }; When I use sizeof() to read a chunk header ... _3DSCHUNKHEADER ChunkHeader; fread(&ChunkHeader, sizeof(_3DSCHUNKHEADER), 1, file); its reading 8 bytes instead of 6, anyone know why? When i break it up into 2 freads ... fread(&ChunkHeader.ChunkID, sizeof(WORD), 1, file); fread(&ChunkHeader.ChunkLength, sizeof(DWROD), 1, file); it works fine. sizeof(WORD) = 2; sizeof(DWORD) = 4; sizeof(_3DSCHUNKHEADER) = 8; Im Confused. Edited by - SoGreen on August 9, 2001 4:58:17 PM

#2 felix9x   Members   

122
Like
Likes
Like

Posted 09 August 2001 - 10:10 AM

Compilers can do this kind of thing to get optimization. Read you compiler documentation to find out more specific information.

#3 SoGreen   Members   

122
Like
Likes
Like

Posted 09 August 2001 - 10:22 AM

Ahh, I didnt think of that, your probably right, time to do some reading, thanks. :p

#4 JonStelly   Members   

127
Like
Likes
Like

Posted 09 August 2001 - 10:33 AM

Look into ''#pragma pack'' Your structures are normally padded to even 8 byte boundaries. You can turn packing on/off using the #pragma pack directive




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.