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

Padding / derived types/ bind(c)

andrew_4619
Honored Contributor II
588 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
Honored Contributor III
586 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?

0 Kudos
andrew_4619
Honored Contributor II
580 Views

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

0 Kudos
andrew_4619
Honored Contributor II
567 Views

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

0 Kudos
Reply