F2225, NEAR/FAR Attribute Mismatch (48787)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 4.0
  • Microsoft FORTRAN Compiler for MS-DOS 4.1
  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN Compiler for MS-DOS 5.1
  • Microsoft FORTRAN compiler for OS/2 4.0
  • Microsoft FORTRAN compiler for OS/2 4.1
  • Microsoft FORTRAN compiler for OS/2 5.0
  • Microsoft FORTRAN compiler for OS/2 5.1

This article was previously published under Q48787

SUMMARY

When using FORTRAN in the large model and calling a subroutine that is declared as NEAR, error F2225 "NEAR/FAR attribute mismatch" is generated if no INTERFACE statement exists for that subroutine.

When the compiler passes a CALL instruction in a large model FORTRAN program, it reserves 4 bytes for the address of the subroutine. If you use the NEAR attribute on the subroutine, only 2 bytes are needed for the subroutine address.

The problem occurs because the compiler assumes the subroutine is type FAR if the compiler reaches the call to the subroutine before the subroutine declaration. If you then specify the subroutine as NEAR, you get the attribute mismatch error.

To eliminate this mismatch, you must use the interface statement at the beginning of the file to explicitly define the subroutine as NEAR, as shown in the following example:
      interface to subroutine mysub [NEAR] ()
      end
				
This procedure lets the compiler know that when it comes across a call to the subroutine mysub, two bytes should be reserved for the address instead of four bytes.

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:KB48787