error calling c functions from gfortran
mike.howell@mchsi.com
mike.howell@mchsi.com
Sat Feb 10 16:47:00 GMT 2007
I get the wrong answer calling c programs from a gfortran program. The same c
functions work when called from a c main program. I guess I need some kind of
interface statement to call c functions from gfortran. Can anyone help me? I
have attached the make file and source code. The shift result is incorrect. A rt
shift on the number 8 should return 4 & lft shift 16.
Thanks, Mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d_shiftf.mak
Type: application/octet-stream
Size: 385 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070210/87e5ba3e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d_shiftf.f
Type: application/octet-stream
Size: 277 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070210/87e5ba3e/attachment-0001.obj>
-------------- next part --------------
/*
c
c.... shifting 1 bit to lft is same as multiplying by 2
c
*/
int lshift_(int Num2Shift, int NumBits )
{
return(Num2Shift << NumBits);
}
-------------- next part --------------
/*
c
c.... shifting 1 bit to rt is same as dividing by 2
c
*/
int rshift_(int Num2Shift, int NumBits )
{
return(Num2Shift >> NumBits);
}
More information about the Fortran
mailing list