Hi all!
I am having trouble compiling the following code:
C code:
#include <stdlib.h>
extern const int foo = -1;
Fortran code:
module cnst_m
use, intrinsic :: iso_c_binding, only: c_int
implicit none
private
public :: &
FOO
integer(kind=c_int), bind(c), protected :: FOO
end module cnst_m
program cnst_p
use cnst_m, only: FOO
implicit none
print *, FOO
stop
end program cnst_p
When using the "-init=(minus_)huge" flag, the compiler returns:
/tmp/ifortSUJ720.o:(.data+0x0): multiple definition of `foo'
./cnst.o:(.rodata+0x0): first defined here
The problem is also present with real initialization.
I would wager this has something to do with the way default initialization is defined.
Thank you very much.
Best regards,
José Rui
連結已複製
What happens if you do not define it in your C code:
extern const int foo;
but do so in Fortran:
integer(c_int), bind(C, name="foo"), protected :: FOO = 1
If this doesn't work, see if you can get help from Intel support.
