Microsoft KB Archive/48787

= F2225, NEAR/FAR Attribute Mismatch =

Article ID: 48787

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 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 &quot;NEAR/FAR attribute mismatch&quot; 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.

Additional query words: kbinf nofps 4.00 4.10 5.00 5.10

Keywords: KB48787

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.