I wouldn't worry that much. C compilers also do insert padding into structures, especially when the elements are not multiples of 4 bytes. Much worse would be sequence
, but that is something different.
Try this equivalent of your derived type in C:
#include <stdio.h>
#include <stdint.h>
#include <complex.h>
typedef struct{
int16_t a;
float complex b;
int16_t c;
} t;
int main(){
t o;
printf("%x %x %x \n",&o.a,&o.b,&o.c);
return 0;
}
My compiler (gcc
on x86_64) alligns the components to addresses that are multiples of 4 bytes even without any optimizations. Even more, the allignment is exactly the same that gfortran
chose with all optimizations enabled.
The same allignment is also used by icc
, ifort
, suncc
and sunf90
.
- The module
iso_c_binding
itself should have no impact on optimizations, bacuse it is only a collection of parameters, typedefs and procedures. It may force you to use more pointers than you would normally do though.