Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Windows structures packing

aliho
Beginner
992 Views
After compiling my project with CVF 6.6C (from DF 5.0) the accelerator keys don't work anymore.

I find out that the length of type t_accel defined in DFWINTY.MOD as follow :
type t_accel
sequence
integer(byte) fvirt
integer(word) key
integer(word) cmd
end type
is now 5 bytes instead of 6 bytes in DF 5.0.

The two functions CreateAcceleratorTable and Copy AcceleratorTable only work with a 6 bytes t_accel type .

In order to avoid further problems, does anyone encounter same packing problem with Windows structures?
0 Kudos
4 Replies
Steven_L_Intel1
Employee
992 Views
Interesting. I don't see any clue in the C declaration of this structure that it should be 6 bytes long, but indeed C thinks it is. I'll pass this along to the Intel Fortran libraries team.
0 Kudos
Steven_L_Intel1
Employee
992 Views
I see what the problem is...
The type is defined as a SEQUENCE type, which means no padding. The C definition of this structure, by C rules, has a length that is rounded up to a multiple of its longest type (word, or 2 bytes). With Fortran, SEQUENCE prevents such padding unless the declaration is compiled /align:sequence.
Removing SEQUENCE is not a solution, as that has other unwanted side-effects. I guess what we'll have to do (for Intel Visual Fortran)is add a dummy field to pad it out to six bytes.
I suggest using your own declaration of this type for now.
0 Kudos
aliho
Beginner
992 Views
Effectively I have created my own structure with manual padding and the interfaces for the associated functions.

But my actual problem is to prevent potential problems of the same kind with other windows structures I use in the project.

I don't know if checking structures with BYTE elements may be sufficient.
0 Kudos
Steven_L_Intel1
Employee
992 Views
I changed my mind regarding the solution - removing SEQUENCE is better as it is less likely to break existing code than adding a dummy field. If a dummy field is added, structure constructors will require source changes, whereas I doubt anyone will notice the removal of SEQUENCE.
0 Kudos
Reply