- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a mixed language project, where I have to use a global datattype. This global variable shold be accessible in the whole c-code, and also in the fortran module.
I folowed the instructions "Using Common External Data in Mixed-Language Programming", however I get the error unresolved external symbol _pres_ referenced in function PACS. Did I forgot something ?
#PACS.f90
module PACS
type, BIND(C):: PACS_RES
character(256) :: msg
character(256) :: state_msg
integer(C_INT) :: state
integer(C_INT) :: state_chg
end type PACS_RES
!DEC$ ATTRIBUTES C, EXTERN :: p_res
type(PACS_RES) p_res
contains
subroutine call_echo
hThread = CreateThread(NULL_SA, 0, LOC(THREAD_call_echo), LOC(ival), 0, LOC(idThread))
! wait until progress has ended
do while ( (p_res%state .NE. PACS_CALL_OK))
if (p_res%state_chg .EQ. 1) then
p_res%state_chg = 0
write(*,*) p_res%state
endif
enddo
end subroutine
end module
#pacs.cxx
struct PACS_RES {
int state;
int state_chg;
char state_msg[256];
};
PACS_RES p_res; // global structure
void call_echo {
if (msg) strcopy(p_res.state_msg, msg);
};"
I folowed the instructions "Using Common External Data in Mixed-Language Programming", however I get the error unresolved external symbol _pres_ referenced in function PACS. Did I forgot something ?
#PACS.f90
module PACS
type, BIND(C):: PACS_RES
character(256) :: msg
character(256) :: state_msg
integer(C_INT) :: state
integer(C_INT) :: state_chg
end type PACS_RES
!DEC$ ATTRIBUTES C, EXTERN :: p_res
type(PACS_RES) p_res
contains
subroutine call_echo
hThread = CreateThread(NULL_SA, 0, LOC(THREAD_call_echo), LOC(ival), 0, LOC(idThread))
! wait until progress has ended
do while ( (p_res%state .NE. PACS_CALL_OK))
if (p_res%state_chg .EQ. 1) then
p_res%state_chg = 0
write(*,*) p_res%state
endif
enddo
end subroutine
end module
#pacs.cxx
struct PACS_RES {
int state;
int state_chg;
char state_msg[256];
};
PACS_RES p_res; // global structure
void call_echo {
if (msg) strcopy(p_res.state_msg, msg);
};"
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Couldn't you rely on iso_c_binding and avoid DEC$ATTRIBUTES ? Surely, you require USE iso_c_binding.
Do you have an extern "C" hidden somewhere in the macros you didn't show us?
Do you have an extern "C" hidden somewhere in the macros you didn't show us?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks as if you have /assume:underscore on, which adds a trailing underscore to all externals. That is not consistent with Windows (it is a Linux convention.)
![](/skins/images/3CECF0550DB8BF54496C114A1FF06FE9/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page