Archived

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

data alignment in VS6

This topic is 5577 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

Yo, I''m having trouble aligning data to 16-byte boundaries for SSE instructions. This is the way I try to do it: __declspec(align(16)) float vector[4]; (declared globally) However, this gets flagged by the compiler with the message: fatal error C1600: unsupported data type If I try __declspec(align(2)) it compiles OK (but is pretty useless . I''m compiling on Visual Studio 6 C++ Standard Edition (so no MS processor pack) with Service Pack 5. Is it something that I''m doing wrong, or is it my cheap compiler? Thanks for your help, Pete

Share this post


Link to post
Share on other sites
Can you use:

#pragma pack(2)

or am I way off base?

---
Make it work.
Make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
Can't you just manually add padding fields until the class has the right memory layout?

#pragma pack

should also work...

And is it a good idea to call a global variable vector?

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

[edited by - Paradigm Shifter on September 3, 2002 8:01:34 AM]

Share this post


Link to post
Share on other sites
> Can''t you just manually add padding fields until the class has the right memory layout?

That would ensure correct alignment within the class, but wouldn''t guarantee an instance of the class will be aligned.

> And is it a good idea to call a global variable vector?

Nope, my code is a big hack at the moment

Share this post


Link to post
Share on other sites
#pragma pack(16) means 16 byte boundaries.

Use #pragma pack(2) for 2 byte boundaries.

---
Make it work.
Make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
I''m not sure why it''s not working. But don''t forget that using malloc or new will not align data, even it''s got a __declspec(align) modifier. You need to use _aligned_malloc or overload operator new yourself.

Actually, looking in the documentation, it says that error is usually a result of applying a service pack and not the corresponding processor pack... I don''t know if that has anything to do with you, but when I tried __declspec(align(16)) with VS.NET, it worked OK.

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Share this post


Link to post
Share on other sites