Click here to Skip to main content
16,008,750 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCString Format method Pin
Anonymous12-Aug-02 23:58
Anonymous12-Aug-02 23:58 
GeneralRe: CString Format method Pin
Christian Graus13-Aug-02 0:01
protectorChristian Graus13-Aug-02 0:01 
GeneralRe: CString Format method Pin
Anonymous13-Aug-02 1:30
Anonymous13-Aug-02 1:30 
GeneralRe: CString Format method Pin
Christian Graus13-Aug-02 1:34
protectorChristian Graus13-Aug-02 1:34 
GeneralRe: CString Format method Pin
Jon Hulatt13-Aug-02 2:29
Jon Hulatt13-Aug-02 2:29 
GeneralRe: CString Format method Pin
[CoY0te]13-Aug-02 1:46
[CoY0te]13-Aug-02 1:46 
GeneralRe: CString Format method Pin
jbarton13-Aug-02 2:50
jbarton13-Aug-02 2:50 
GeneralByte Alignment Pin
solosnake12-Aug-02 23:17
solosnake12-Aug-02 23:17 
Hello

I'm having some problems with byte alignment. I'm writing a graphics editor for particle effects for games. The effects are edited on a PC and exported to a file which is read by a PlayStation2. The code for the PS2 is compiled under GCC, the editor with VC++ 6.0 (Service Packs installed).

For memory reasons I want to be able to use the file I load as the structure directly, so it must be stored witht the correct byte alignment to be correctly read by the PS2 (and to benefit from possible later VPU optimisations). I have set the VC++ project settings to be 16 byte aligned by default. I have also used #pragma pack(16) before critical structures.

I noticed however that for some x87 asm I wrote that the structures were not being 16 byte aligned. VC++ seemed to be completely ignoring ALL my efforts to force it to align structures.

Now when reading the structure, if I tell gcc that the structure is 16-byte aligned (using the __attribute__(align(16)) directive) the structure is read incorrectly. If VC++ had written my structure with 16 alignment this should not be the case? However when I switch off the alignment directive on gcc the struct is loaded correctly.

My questions are:
1)
How can I declare a structure in VC++ such that it will have specific alignement? I think it is as follows:
#pragma pack(16) or #pragma pack(push,16) followed by #pragma pack(pop) bracketing the struct declaration. But my experience seems to be to the contrary.

2) How can I check this is actually working?
3) How can I check the alignment of a pointer at runtime?

If anyone has any experiences in this area, and want to tell me about them, please do!

Thanks to anyone who helps,

- solosnake




GeneralRe: Byte Alignment Pin
Tomasz Sowinski13-Aug-02 0:40
Tomasz Sowinski13-Aug-02 0:40 
GeneralRe: Byte Alignment Pin
Anonymous13-Aug-02 1:07
Anonymous13-Aug-02 1:07 
GeneralRe: Byte Alignment Pin
Brian Azzopardi13-Aug-02 4:03
Brian Azzopardi13-Aug-02 4:03 
GeneralRe: Byte Alignment Pin
JT Anderson13-Aug-02 6:45
JT Anderson13-Aug-02 6:45 
GeneralRe: Byte Alignment Pin
solosnake14-Aug-02 1:44
solosnake14-Aug-02 1:44 
General1. Simple techniques for dragging/sizing controls | 2. Non cubical dialogs/controls Pin
BlackSmith12-Aug-02 23:08
BlackSmith12-Aug-02 23:08 
GeneralDatabase Connection with SDK Pin
vin12-Aug-02 22:36
vin12-Aug-02 22:36 
GeneralRe: Database Connection with SDK Pin
Ranjan Banerji13-Aug-02 2:38
Ranjan Banerji13-Aug-02 2:38 
GeneralRe: Database Connection with SDK Pin
pépé13-Aug-02 3:05
pépé13-Aug-02 3:05 
GeneralMarking a row in a CListCtrl Pin
Poul Haahr Klemmensen12-Aug-02 22:10
Poul Haahr Klemmensen12-Aug-02 22:10 
GeneralRe: Marking a row in a CListCtrl Pin
567890123412-Aug-02 22:34
567890123412-Aug-02 22:34 
GeneralRe: Marking a row in a CListCtrl Pin
Stefan Pedersen12-Aug-02 22:34
Stefan Pedersen12-Aug-02 22:34 
GeneralRe: Marking a row in a CListCtrl Pin
Stefan Pedersen12-Aug-02 22:37
Stefan Pedersen12-Aug-02 22:37 
Questionwhat is PeekAndPump()?? Pin
tulc_kris12-Aug-02 21:57
tulc_kris12-Aug-02 21:57 
AnswerRe: what is PeekAndPump()?? Pin
jmkhael12-Aug-02 23:27
jmkhael12-Aug-02 23:27 
AnswerRe: what is PeekAndPump()?? Pin
Tomasz Sowinski13-Aug-02 0:44
Tomasz Sowinski13-Aug-02 0:44 
GeneralThread and serial port Pin
Mavrock12-Aug-02 19:25
Mavrock12-Aug-02 19:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.