- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using ISO_C_BINDING to access 32-bit global variables in C object code from Fortran. In the C object code, globals are aligned at 4-byte boundaries, but Fortran object code expects 8-byte boundaries.
Example code:
/* data.c */
int global1=1;
! globals.f90
module globals
use iso_c_binding
integer(C_int), bind(C,name="global1") :: global1
end module globals
use globals
write (*,*) 'global1=',global1
end
$ icc -c data.c
$ ifort -c global.f90
$ ifort -o global global.o data.o
ld: Warning: alignment 4 of symbol `global1' in data.o is smaller than 8 in global.o
With the 32-bit compilers, both align at 4-byte boundaries. With 64-bit, Fortran switches to 8-byte boundaries, while icc and gcc both remain at 4-byte. I have tried passing various alignement switches to ifort, but get the same results.
The resulting code seems to work, so perhaps the linker can handle the problem and produce correct code. It would be nice to know if this warning can in fact be safely ignored, and if there are any compiler switches or directives to get the correct result. It also seems likely to be a compiler bug.
My compiler version is 12.1.0, running on a Fedora 15
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page