Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SUBROUTINE TESTCPP ( II, JJ, KK, LL )
- INCLUDE 'COMON4.INS'
- integer*4, external :: CPPFUNCTION
- INTEGER a, b, c, test
- IF (.NOT. IFLAG) RETURN
- a = ICON(II)
- b = ICON(II + 1)
- test = CPPFUNCTION( a , b, c )
- WRITE ( ITERM, * ) 'C = ', c
- RETURN
- END
- extern "C" {
- void _CPPFUNCTION(int a, int b, int *c);
- }
- void _CPPFUNCTION(int a, int b, int *c) {
- *c = a + b;
- }
- cl /nologo /MD /c /W3 /O2 /FD /EHsc /errorReport:prompt /D"MSWINDOWS" /D"WIN32" ^
- /D"_WINDOWS" /D"NDEBUG" "cpp_code.cpp"
- IFORT /nologo /Od /Oy- /assume:buffered_io /traceback /libs:dll /threads /c /Qip ^
- /extend_source:132 /noaltparam /fpscomp:logicals /warn:nodeclarations ^
- /warn:unused /warn:truncated_source /Qauto /Op /iface:cvf /define:DLLI ^
- /include:"C:Program Files (x86)PTIPSSE32PSSLIB" ^
- /object:"fort_code.OBJ" ^
- "fort_code.f"
- lib /out:fort_cpp.lib fort_code.obj cpp_code.obj
- ifort /nologo /assume:buffered_io /traceback /libs:dll /threads /c /Qip /extend_source:132 /noaltparam /fpscomp:logicals /Qprec /warn:declarations /warn:unused /warn:truncated_source /Qauto /fp:source /iface:cvf /define:DLLI /include:"C:Program Files (x86)PTIPSSE32PSSLIB" /object:"C:tempINIT_62028911hw2ap_conec.obj" /module:"C:tempINIT_620289" "11hw2ap_conec.f"
- ifort /nologo /assume:buffered_io /traceback /libs:dll /threads /c /Qip /extend_source:132 /noaltparam /fpscomp:logicals /Qprec /warn:declarations /warn:unused /warn:truncated_source /Qauto /fp:source /iface:cvf /define:DLLI /include:"C:Program Files (x86)PTIPSSE32PSSLIB" /object:"C:tempINIT_62028911hw2ap_conet.obj" /module:"C:tempINIT_620289" "11hw2ap_conet.f"
- link /INCREMENTAL:NO /NOLOGO /DLL /SUBSYSTEM:WINDOWS /MACHINE:X86 /ERRORREPORT:PROMPT @"C:tempINIT_620289linkfilestod9p1.txt" /OUT:"C:tempINIT_62028911hw2ap_dsusr.dll" /map:"C:tempINIT_62028911hw2ap_dsusr.map"
- fort_cpp.lib(fort_code.obj) : error LNK2019: unresolved external symbol _CPPFUNCTION@12 referenced in function _TESTCPP
- C:tempINIT_62028911hw2ap_dsusr.dll : fatal error LNK1120: 1 unresolved externals
- ERROR during link(1)... Aborted
- SUBROUTINE CONEC
- C
- INCLUDE 'COMON4.INS'
- C
- CALL TESTCPP ( 55791, 0, 0, 0)
- C
- RETURN
- END
- SUBROUTINE CONET
- C
- INCLUDE 'COMON4.INS'
- C
- IF (.NOT. IFLAG) GO TO 9000
- C
- C NETWORK MONITORING MODELS
- C
- C
- 9000 CONTINUE
- C
- RETURN
- END
- program example
- use iso_c_binding
- implicit none
- interface
- integer(c_int) function add1(x) bind(C,name="add1")
- !DEC$ ATTRIBUTES DLLEXPORT :: add1
- use iso_c_binding
- integer(c_int), value :: x
- end function add1
- end interface
- call callingadd1()
- contains
- subroutine callingadd1()
- write(*,*) '1+1=', add1(1)
- end subroutine callingadd1
- end program example
- extern "C" {
- int add1(int x);
- }
- int add1(int x) {
- return(x+1);
- }
- subroutine callingadd1() bind(C, name="callingadd1")
- !DEC$ ATTRIBUTES DLLEXPORT :: callingadd1
- use iso_c_binding
- implicit none
- interface
- integer(c_int) function add1(x) bind(C,name="add1")
- !DEC$ ATTRIBUTES DLLEXPORT :: add1
- use iso_c_binding
- integer(c_int), value :: x
- end function add1
- end interface
- write(*,*) '1+1=', add1(1)
- end subroutine callingadd1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement