This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

error calling c functions from gfortran


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

Attachment: d_shiftf.mak
Description: Binary data

Attachment: d_shiftf.f
Description: Binary data

/*
c
c.... shifting 1 bit to lft is same as multiplying by 2
c
*/

int lshift_(int Num2Shift, int NumBits )

{
	return(Num2Shift << NumBits);
}
/*
c
c.... shifting 1 bit to rt is same as dividing by 2
c
*/

int rshift_(int Num2Shift, int NumBits )

{
	return(Num2Shift >> NumBits);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]