KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've seen countless questions of the form "I don't like padding how do I turn it off", but have yet to find anything about forcing the compiler to provide extra padding. The specific case that I have looks like struct particle{ vect2 s; vect2 v; int rX; int rY; double mass; int boxNum; }; Where vect2 is a simple struct {double x; double y;} vect2 . In order to use SSE2, I need to be able to load a pair of doubles, aligned to 16 byte boundaries. This used to work, until I added the extra int , pushing my struct size from 48 bytes to 56 bytes. The result is segfaults. Is there some kind of compiler directive I can use that either says "pad this struct to make it a multiple of 16 bytes long", or "this struct has an alignment of 16-bytes"? I know I could do it manually (tacking on an extra char[12], for example), but I'd really rather just tell the compiler(GCC, preferably ICC compatible), and not have to do it manually if I change the struct in future.
Tags (comma-separated)
Save Edits
Cancel