I agree with Kenno: the #ifdef stuff is bogus. This is what Fortran 2003's iso_c_binding module is for. Try int32_t on the C side and integer(c_int32_t) on the Fortran side. If you're using gfortran, it needs to be version 4.3 or later.