To my knowledge alignment is sorted out by the compiler, which makes sense to me, since it needs to create the code to access the structures.
I’ve only ever had to turn off alignment, i.e. I set it to 1 byte alignment to access tightly packed structures. Therefore I’m not sure exactly how to solve your problem. However I think that the pack pragma is what you are looking for.
Have a look at the following URL for more info
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_predir_pack.asp
Since you are dealing with a short you may need to do some casting magic. By that I mean allocate it as a block of ULONGLONGs (I can’t remember for sure if that is an 8 byte type) or something that is 8 byte aligned. Then access it as a series of shorts via a cast.
Richard McNally
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@conexant.com
Sent: Tuesday, 1 February 2005 12:28 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to align static data structures in a driver?
Hi All,
Say I have a huge structure of shorts declared globally:
static short myArray={1, 2, 3, 4, 5, …, 16000}
I want myArray[0] to be 8-Byte aligned. Is there a way to tell the DDK compiler this requirement? I know in later application compilers there is a __declspec(align) directive. Will this also work in a driver?
Who actually does the alignment in this case, is it the compiler, or the linker, or both in conjunction enforce the alignment?
Thanks,
James
********************** Legal Disclaimer ****************************
“This email may contain confidential and privileged material for the sole use of the intended recipient. Any unauthorized review, use or distribution by others is strictly prohibited. If you have received the message in error, please advise the sender by reply email and delete the message. Thank you.”
**********************************************************************
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@dsto.defence.gov.au
To unsubscribe send a blank email to xxxxx@lists.osr.com