Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

mixed language common variables

jaeger0
Beginner
286 Views
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);

};"
0 Kudos
2 Replies
TimP
Honored Contributor III
286 Views
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?
0 Kudos
Steven_L_Intel1
Employee
286 Views
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.)
0 Kudos
Reply