Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Padding / derived types/ bind(c)

andrew_4619
Honored Contributor I
146 Views

type, bind(c) :: fred
    integer(2) :: JJ
    integer(4) :: KK
end type

type :: bill
    sequence
    integer(2) :: JJ
    integer(4) :: KK
end type

type(fred) :: afred
type(bill) :: abill

So with Intel(R) Visual Fortran Compiler 19.1.1.216 and no fancy compiler options
afred is 8 bytes ( 2 bytes padding )
abill is 6 bytes ( no padding but an alignment warning )

Does BIND(C) imply padding if the companion C compiler would do that by default? Is there any standard way of dealing with this issue?

For a specific windows API call I need the unpadded version. I would also like to know the size of abill. C_SIZEOF(abill) is not an option because we get the abill is non-interoperable error on the latest compiler. Yes I can use sizeof(abill) which is non-standard what standard option is available?

0 Kudos
3 Replies
Steve_Lionel
Black Belt Retired Employee
144 Views

Yes, an interoperable type pads if the "companion C processor" would do so. There is no standard syntax to eliminate such padding.

I'm curious - which API structure is involved?

andrew_4619
Honored Contributor I
138 Views

Bitmaps (BMP) files that have a structure that goes back to 16 bit OS..... The problem is not a problem just an irritation.....

andrew_4619
Honored Contributor I
125 Views

Well a guess sequence is standard so that and storage_size will do what I want.....

Reply