Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with __declspec(align)

Status
Not open for further replies.

hankgao0703

Programmer
Jul 18, 2001
27
CA
In one of my projects, I have to use __declspec(align(16) to force the memory allocation is done at 16 bytes boundary, but I alway get error:

C1306(or else) => Unsupported Data Type

When I remove __declspec(align(16)) modifier, everything seems ok.

by the way, based on the MS document, __declspec(align(xx)) is used to specify boundary for structure, Can I use it for memory allocation for an array?

Thanks in advance!

 
Sure,

I declare a structure type as the following:

__declspec(align(16))
struct MyStruct {
//
short shortArray[12][64];
.....
}myVarName;

and the compiler reports:
fatal error C1600: unsupported data type
When I doule clike this error message in the build window, I can go nowhere in the sourcecode.

It takes me quite a while to figure out the reason is the __declspec(align(16)) modifier.


 
I don't have problem with the code fragment of yours. What kind of project are you trying to build?

The doc for C1600 said it could due to "imcomplete installation". May be you should reinstall VC.NET.

Sorry if this is not helpful.

Shyan
 
"Incomplete installation"? probably, I never thought of this reason, and I will check it out.

I don't quite understand why you say VC.NET, I am using VC6.00, Do I have to use VC.NET before I can use __declspec(align(xx))?

 
Something is not right here...Don't reinstall your installation yet.

__declspec() do not support align() in VC6. It only works on VC.NET.

in VC6, you have to use #pragma pack(16), or its variations:
Code:
// Save current alignment setting to interanl compiler stack and 
// set alignment setting to 16
#pragma pack(push, 16)

// ...
// put your struct here
// ...

// Restore previous alignemnt setting
#pragma pack(pop)

HTH
Shyan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top