Last active
June 16, 2016 14:50
-
-
Save baptistelabat/f4b0bbe69ea31974fb27da27fb23760d to your computer and use it in GitHub Desktop.
C++ call from fortran http://www.neurophys.wisc.edu/comp/docs/not017/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -c test.cpp -o test.o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INTEGER CR2 | |
N=10 | |
CALL CR1(N,M) | |
WRITE(6,20) N,M | |
20 FORMAT(' The square of',I3,' is',I4) | |
K=CR2(N) | |
WRITE(6,30) N,K | |
30 FORMAT(' The cube of',I3,' is',I15) | |
CALL EXIT | |
END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" | |
{ | |
void __stdcall CR1(int *,int *); | |
int __stdcall CR2(int *); | |
} | |
void __stdcall CR1(int *n, int *m) | |
{ | |
// Compute the square of n, return in m | |
int k; | |
k=*n; | |
*m=k*k; | |
return; | |
} | |
int __stdcall CR2(int *n) | |
// Compute the cube of n | |
{ | |
int m,k; | |
k=*n; | |
m=k*k*k; | |
return m; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment