- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with 'name=' option with bind(C,):
integer(kind=c_int), bind(C, name="foo"), protected :: FOO !<-- Note name= option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Makes no difference here.
Thank you very much.
Best regards,
José Rui
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page